Fix crash in qt_qpa_core_dispatcher() at application exit.

In some situations it is possible to get events when QCoreApplication
has already cleared the 'self' pointer and will thus not return an
instance. For example, destroying screen at application exit when
there are parentless dialogs open will result in hiding the dialog,
which at least in Windows causes a call to
QWindowSystemInterface::handleExposeEvent() which will need the core
dispatcher down the line.

Fixed the crash by checking if the QCoreApplication instance is valid
instead of blindly using it. This should cause no problem as unhandled
events are simply queued.

Task-number: QTBUG-26061
Change-Id: Ide2350a62208433728e0271192c1da4b1efacc9b
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
This commit is contained in:
Miikka Heikkinen 2012-06-08 10:20:46 +03:00 committed by Qt by Nokia
parent a15aa822b7
commit f2df9cef75

View File

@ -93,7 +93,12 @@ public:
{ return platform_theme; }
static QAbstractEventDispatcher *qt_qpa_core_dispatcher()
{ return QCoreApplication::instance()->d_func()->threadData->eventDispatcher; }
{
if (QCoreApplication::instance())
return QCoreApplication::instance()->d_func()->threadData->eventDispatcher;
else
return 0;
}
static void processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *e);
static void processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent *e);