diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-06-02 10:59:21 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-06-03 18:40:34 +0200 |
commit | 87d32424de2f471a520c1f3ba0c3035fbff7ee06 (patch) | |
tree | d747902db6df974ef010c90e9ce1b0bd7368260b /src/gui/painting/qimagescale_sse4.cpp | |
parent | 6a31a7b024679c4dcbcf8120b06db0a17fa219ce (diff) |
Do not multithread if already in a global threadpool thread
This can lead to a deadlock if we block all the worker threads, waiting
for the worker threads to finish.
Pick-to: 5.15
Fixes: QTBUG-84619
Change-Id: I92b7f96007897d86ece0c34223bab0df4ccbed9a
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Diffstat (limited to 'src/gui/painting/qimagescale_sse4.cpp')
-rw-r--r-- | src/gui/painting/qimagescale_sse4.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/gui/painting/qimagescale_sse4.cpp b/src/gui/painting/qimagescale_sse4.cpp index 1760e72f65..70cfa08d95 100644 --- a/src/gui/painting/qimagescale_sse4.cpp +++ b/src/gui/painting/qimagescale_sse4.cpp @@ -59,12 +59,13 @@ static inline void multithread_pixels_function(QImageScaleInfo *isi, int dh, con #if QT_CONFIG(thread) && !defined(Q_OS_WASM) int segments = (qsizetype(isi->sh) * isi->sw) / (1<<16); segments = std::min(segments, dh); - if (segments > 1) { + QThreadPool *threadPool = QThreadPool::globalInstance(); + if (segments > 1 && !threadPool->contains(QThread::currentThread())) { QSemaphore semaphore; int y = 0; for (int i = 0; i < segments; ++i) { int yn = (dh - y) / (segments - i); - QThreadPool::globalInstance()->start([&, y, yn]() { + threadPool->start([&, y, yn]() { scaleSection(y, y + yn); semaphore.release(1); }); |