Commit 4c71db75 authored by Tor Arne Vestbø's avatar Tor Arne Vestbø
Browse files

QWindow::destroy(): only reset QGuiApp::focus_window and friends as a last resort


Resetting focus_window and other internal QGuiApplication variables before
calling setVisible(false) and destroying the platform window means that the
platform window can't reason about whether or not it was the focus window
unless it can resolve that using native APIs. We should let the platform
window take care of resetting the focus window and related states, and
only execute our fallback logic if the plugin doesn't do the right
thing.

We also use QPA to update the state instead of modifying the internal
QGuiApplication variables directly, so that events and signals are
emitted as a result of the reset.

The QLineEdit test gets two added calls to processEvents(), since
assuming that activateWindow() is synchronous is not correct, and
would result in the QMenu resetting the focus window to 0 on destroy.

Task-number: QTBUG-46414
Change-Id: I562788393ed0ffd77d7a4be2279862322f721c1a
Reviewed-by: default avatarBłażej Szczygieł <spaz16@wp.pl>
Reviewed-by: default avatarTor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
Showing with 61 additions and 12 deletions
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment