summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@qt.io>2020-12-09 16:31:41 +0100
committerMorten Johan Sørvig <morten.sorvig@qt.io>2020-12-21 22:48:29 +0000
commitb3b95670b2f7e43cfe49fa90f2dffa74b82c160f (patch)
treec6528b933db54bd942ceb95a54ea44d182f433b9 /src/corelib/thread
parentcd6d805d9368a0e84cc20a416ab88603c4be6a9c (diff)
Call QEventDispatcher::startingUp() on thread start
...instead of during createEventDispatcher(). This way, startingUp() will be called [on the thread being started] also for custom event dispatchers installed with QThread::setEventDispatcher(). This prevents crashes when installing event dispatches which expects that startingUp() will be called. Crash reproducible with test case from QTBUG-51961. Change-Id: I71bd696539689d928a61ff9b47d05297cf803b2f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/thread')
-rw-r--r--src/corelib/thread/qthread.cpp1
-rw-r--r--src/corelib/thread/qthread_unix.cpp1
-rw-r--r--src/corelib/thread/qthread_win.cpp1
3 files changed, 2 insertions, 1 deletions
diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp
index 543c491201..3453fd0fc1 100644
--- a/src/corelib/thread/qthread.cpp
+++ b/src/corelib/thread/qthread.cpp
@@ -125,7 +125,6 @@ QAbstractEventDispatcher *QThreadData::createEventDispatcher()
{
QAbstractEventDispatcher *ed = QThreadPrivate::createEventDispatcher(this);
eventDispatcher.storeRelease(ed);
- ed->startingUp();
return ed;
}
diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp
index f4d4914efc..8d2c83d519 100644
--- a/src/corelib/thread/qthread_unix.cpp
+++ b/src/corelib/thread/qthread_unix.cpp
@@ -308,6 +308,7 @@ void *QThreadPrivate::start(void *arg)
}
data->ensureEventDispatcher();
+ data->eventDispatcher.loadRelaxed()->startingUp();
#if (defined(Q_OS_LINUX) || defined(Q_OS_MAC) || defined(Q_OS_QNX))
{
diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp
index b59a9d1bb4..820ffa1149 100644
--- a/src/corelib/thread/qthread_win.cpp
+++ b/src/corelib/thread/qthread_win.cpp
@@ -312,6 +312,7 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi
}
data->ensureEventDispatcher();
+ data->eventDispatcher.loadRelaxed()->startingUp();
#if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC)
// sets the name of the current thread.