Details
Description
When composing text using an input method (I used "Pinyin - Simplified"), the input method session gets cancelled whenever a widget in the same window gets destructed.
In our application, updates from another thread are send to the main thread and cause some widgets to be created/destructed. When such an update happens while the input method widget is visible, it closes the input method widget.
In attachment I added a minimal example. To mimic updates which destruct widgets, I create a new QLabel and call deleteLater() every second. As you will notice it is impossible to compose text using the input method this way.
This is a regression (in Qt 5.6.0 this didn't happen). I think it got introduced by https://codereview.qt-project.org/c/qt/qtbase/+/203859. The intention here was to cancel a composition session when the focus changes, but in my example the focus doesn't change and still this code is triggered.