diff options
author | Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com> | 2015-03-12 14:00:52 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com> | 2016-01-29 19:29:14 +0000 |
commit | 4c71db756741d35ccb32dc4c32aa1823264c85df (patch) | |
tree | 2c043336b452c689db3eb5549c915520dbd382c4 /src/widgets/accessible/qaccessiblewidgetfactory.cpp | |
parent | 164c631d807d80a7dc2b19b8c55bc83734be9312 (diff) |
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: Błażej Szczygieł <spaz16@wp.pl>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
Diffstat (limited to 'src/widgets/accessible/qaccessiblewidgetfactory.cpp')
-rw-r--r-- | src/widgets/accessible/qaccessiblewidgetfactory.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/widgets/accessible/qaccessiblewidgetfactory.cpp b/src/widgets/accessible/qaccessiblewidgetfactory.cpp index 4fa7c89482..00e21da34d 100644 --- a/src/widgets/accessible/qaccessiblewidgetfactory.cpp +++ b/src/widgets/accessible/qaccessiblewidgetfactory.cpp @@ -43,6 +43,7 @@ #include <qtreeview.h> #include <qvariant.h> #include <qaccessible.h> +#include <private/qwidget_p.h> #ifndef QT_NO_ACCESSIBILITY @@ -53,7 +54,15 @@ QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *obje QAccessibleInterface *iface = 0; if (!object || !object->isWidgetType()) return iface; + + // QWidget emits destroyed() from its destructor instead of letting the QObject + // destructor do it, which means the QWidget is unregistered from the accessibillity + // cache. But QWidget destruction also emits enter and leave events, which may end + // up here, so we have to ensure that we don't fill the cache with an entry of + // a widget that is going away. QWidget *widget = static_cast<QWidget*>(object); + if (QWidgetPrivate::get(widget)->data.in_destructor) + return iface; if (false) { #ifndef QT_NO_LINEEDIT |