summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qwineventnotifier.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/kernel/qwineventnotifier.cpp')
-rw-r--r--src/corelib/kernel/qwineventnotifier.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/corelib/kernel/qwineventnotifier.cpp b/src/corelib/kernel/qwineventnotifier.cpp
index c694237dc3..d2c623d489 100644
--- a/src/corelib/kernel/qwineventnotifier.cpp
+++ b/src/corelib/kernel/qwineventnotifier.cpp
@@ -140,11 +140,11 @@ QWinEventNotifier::QWinEventNotifier(HANDLE hEvent, QObject *parent)
{
Q_D(QWinEventNotifier);
QAbstractEventDispatcher *eventDispatcher = d->threadData->eventDispatcher.load();
- if (!eventDispatcher) {
+ if (Q_UNLIKELY(!eventDispatcher)) {
qWarning("QWinEventNotifier: Can only be used with threads started with QThread");
- } else {
- eventDispatcher->registerEventNotifier(this);
+ return;
}
+ eventDispatcher->registerEventNotifier(this);
d->enabled = true;
}
@@ -215,6 +215,10 @@ void QWinEventNotifier::setEnabled(bool enable)
QAbstractEventDispatcher *eventDispatcher = d->threadData->eventDispatcher.load();
if (!eventDispatcher) // perhaps application is shutting down
return;
+ if (Q_UNLIKELY(thread() != QThread::currentThread())) {
+ qWarning("QWinEventNotifier: Event notifiers cannot be enabled or disabled from another thread");
+ return;
+ }
if (enable)
eventDispatcher->registerEventNotifier(this);