From afe3c30759d1bf9f52278d8dc40f85a93a1d963b Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Fri, 26 Feb 2016 13:56:55 -0800 Subject: Don't create accessible interface for QWidgets being destroyed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I975ee556913707e8595b2a89f1bba4299187bcfb Reviewed-by: Wayne Arnold Reviewed-by: Jan Arve Sæther --- src/widgets/accessible/qaccessiblewidgetfactory.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/widgets/accessible') diff --git a/src/widgets/accessible/qaccessiblewidgetfactory.cpp b/src/widgets/accessible/qaccessiblewidgetfactory.cpp index 4fa7c89482..261bc69000 100644 --- a/src/widgets/accessible/qaccessiblewidgetfactory.cpp +++ b/src/widgets/accessible/qaccessiblewidgetfactory.cpp @@ -33,6 +33,7 @@ #include "qaccessiblewidgets_p.h" #include "qaccessiblemenu_p.h" +#include "private/qwidget_p.h" #include "simplewidgets_p.h" #include "rangecontrols_p.h" #include "complexwidgets_p.h" @@ -53,7 +54,15 @@ QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *obje QAccessibleInterface *iface = 0; if (!object || !object->isWidgetType()) return iface; + QWidget *widget = static_cast(object); + // 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. + if (QWidgetPrivate::get(widget)->data.in_destructor) + return iface; if (false) { #ifndef QT_NO_LINEEDIT -- cgit v1.2.3