forked from qt-creator/qt-creator
Avoid starting threads from the wrong hosting thread
This should be safe for QThreadPool, but we are still fixing an underlying bug, QTBUG-99775, and Qt Creator may just want to avoid the issue altogether. Change-Id: I50041cc6f5974d234b1a07be5cb19108fba897c7 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -408,7 +408,10 @@ QFuture<ResultType> runAsync_internal(QThreadPool *pool,
|
||||
QFuture<ResultType> future = job->future();
|
||||
if (pool) {
|
||||
job->setThreadPool(pool);
|
||||
if (QThread::currentThread() == pool->thread())
|
||||
pool->start(job);
|
||||
else
|
||||
QMetaObject::invokeMethod(pool, [pool, job]() { pool->start(job); }, Qt::QueuedConnection);
|
||||
} else {
|
||||
auto thread = new Internal::RunnableThread(job);
|
||||
if (stackSize)
|
||||
|
Reference in New Issue
Block a user