QWinEventNotifier: Fix exit crash

Make sure the wait handle is unregistered even though
there is no event dispatcher in QWinEventNotifier::setEnabled().

Task-number: QTBUG-64152
Task-number: QTCREATORBUG-19175
Change-Id: I608b95adc7cb874bc52dc5bf0e9f51b443b54ebc
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Friedemann Kleint 2017-11-06 14:31:29 +01:00
parent 3e5dde4766
commit 28c1e17aef

View File

@ -199,8 +199,11 @@ void QWinEventNotifier::setEnabled(bool enable)
d->enabled = enable;
QAbstractEventDispatcher *eventDispatcher = d->threadData->eventDispatcher.load();
if (!eventDispatcher) // perhaps application is shutting down
if (!eventDispatcher) { // perhaps application is shutting down
if (!enable && d->waitHandle != nullptr)
d->unregisterWaitObject();
return;
}
if (Q_UNLIKELY(thread() != QThread::currentThread())) {
qWarning("QWinEventNotifier: Event notifiers cannot be enabled or disabled from another thread");
return;