From 948f8ce2ecb2d6d2713279311d6090268321f0fb Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 28 Aug 2018 17:51:51 -0700 Subject: QWinEventNotifier: fix crash on application shutdown The event dispatcher can be null already but we may have outstanding QWinEventNotifier objects (like in a QProcess). Patch-By: Tamas Karpati Task-number: QTBUG-70214 Change-Id: I5e432e273def425ea334fffd154f34abfd6cb11a Reviewed-by: Friedemann Kleint --- src/corelib/kernel/qwineventnotifier.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/corelib/kernel/qwineventnotifier.cpp b/src/corelib/kernel/qwineventnotifier.cpp index 24de491326..fe086acb5d 100644 --- a/src/corelib/kernel/qwineventnotifier.cpp +++ b/src/corelib/kernel/qwineventnotifier.cpp @@ -256,6 +256,14 @@ static void CALLBACK wfsoCallback(void *context, BOOLEAN /*ignore*/) { QWinEventNotifierPrivate *nd = reinterpret_cast(context); QAbstractEventDispatcher *eventDispatcher = nd->threadData->eventDispatcher.load(); + + // Happens when Q(Core)Application is destroyed before QWinEventNotifier. + // https://bugreports.qt.io/browse/QTBUG-70214 + if (!eventDispatcher) { // perhaps application is shutting down + qWarning("QWinEventNotifier: no event dispatcher, application shutting down? Cannot deliver event."); + return; + } + QEventDispatcherWin32Private *edp = QEventDispatcherWin32Private::get( static_cast(eventDispatcher)); ++nd->signaledCount; -- cgit v1.2.3