Revert "Avoid starting threads from the wrong hosting thread"

This reverts commit 1421694d17.

The commit broke e.g. Utils::mapReduce(....).results() in the main
thread. Since the main thread blocks, it cannot start a new thread.

Change-Id: I63abd07bcf002546740d0a7627f1fd2007c8b70c
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
This commit is contained in:
Eike Ziller
2022-01-18 09:47:28 +01:00
parent 62c36f516b
commit f884ff2160

View File

@@ -408,10 +408,7 @@ QFuture<ResultType> runAsync_internal(QThreadPool *pool,
QFuture<ResultType> future = job->future(); QFuture<ResultType> future = job->future();
if (pool) { if (pool) {
job->setThreadPool(pool); job->setThreadPool(pool);
if (QThread::currentThread() == pool->thread()) pool->start(job);
pool->start(job);
else
QMetaObject::invokeMethod(pool, [pool, job]() { pool->start(job); }, Qt::QueuedConnection);
} else { } else {
auto thread = new Internal::RunnableThread(job); auto thread = new Internal::RunnableThread(job);
if (stackSize) if (stackSize)