summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-12 09:44:27 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-12 16:28:47 +0200
commitb89d68f8610fa74c90905ffde4e1479ac78ddf45 (patch)
treef31316e945e8c03b82f2f7ecea93b72e2fce8dc1
parent1dc58eb40ae07a191c37f583bc0a8a1a3f5bca4f (diff)
Protect QImage work on shutdown
If the thread pool was not created, or already deleted, make sure the QImage routines can still run as they could before. Fixes: QTBUG-87320 Change-Id: I4105a68b6ae0637faf82cdda5f5ae44298759396 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> (cherry picked from commit 0aa8925f1acd47cadc71483cac97d202444d15db)
-rw-r--r--src/gui/image/qimage_conversions.cpp6
-rw-r--r--src/gui/painting/qimagescale.cpp2
-rw-r--r--src/gui/painting/qimagescale_neon.cpp2
-rw-r--r--src/gui/painting/qimagescale_sse4.cpp2
4 files changed, 6 insertions, 6 deletions
diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp
index e804b3b788..9257ab8cfe 100644
--- a/src/gui/image/qimage_conversions.cpp
+++ b/src/gui/image/qimage_conversions.cpp
@@ -237,7 +237,7 @@ void convert_generic(QImageData *dest, const QImageData *src, Qt::ImageConversio
segments = std::min(segments, src->height);
QThreadPool *threadPool = QThreadPool::globalInstance();
- if (segments <= 1 || threadPool->contains(QThread::currentThread()))
+ if (segments <= 1 || !threadPool || threadPool->contains(QThread::currentThread()))
return convertSegment(0, src->height);
QSemaphore semaphore;
@@ -292,7 +292,7 @@ void convert_generic_to_rgb64(QImageData *dest, const QImageData *src, Qt::Image
segments = std::min(segments, src->height);
QThreadPool *threadPool = QThreadPool::globalInstance();
- if (segments <= 1 || threadPool->contains(QThread::currentThread()))
+ if (segments <= 1 || !threadPool || threadPool->contains(QThread::currentThread()))
return convertSegment(0, src->height);
QSemaphore semaphore;
@@ -399,7 +399,7 @@ bool convert_generic_inplace(QImageData *data, QImage::Format dst_format, Qt::Im
int segments = data->nbytes / (1<<16);
segments = std::min(segments, data->height);
QThreadPool *threadPool = QThreadPool::globalInstance();
- if (segments > 1 && !threadPool->contains(QThread::currentThread())) {
+ if (segments > 1 && threadPool && !threadPool->contains(QThread::currentThread())) {
QSemaphore semaphore;
int y = 0;
for (int i = 0; i < segments; ++i) {
diff --git a/src/gui/painting/qimagescale.cpp b/src/gui/painting/qimagescale.cpp
index aac1e20f7b..86057cdd33 100644
--- a/src/gui/painting/qimagescale.cpp
+++ b/src/gui/painting/qimagescale.cpp
@@ -308,7 +308,7 @@ static inline void multithread_pixels_function(QImageScaleInfo *isi, int dh, con
int segments = (qsizetype(isi->sh) * isi->sw) / (1<<16);
segments = std::min(segments, dh);
QThreadPool *threadPool = QThreadPool::globalInstance();
- if (segments > 1 && !threadPool->contains(QThread::currentThread())) {
+ if (segments > 1 && threadPool && !threadPool->contains(QThread::currentThread())) {
QSemaphore semaphore;
int y = 0;
for (int i = 0; i < segments; ++i) {
diff --git a/src/gui/painting/qimagescale_neon.cpp b/src/gui/painting/qimagescale_neon.cpp
index 046e56b419..3c87ac8773 100644
--- a/src/gui/painting/qimagescale_neon.cpp
+++ b/src/gui/painting/qimagescale_neon.cpp
@@ -59,7 +59,7 @@ static inline void multithread_pixels_function(QImageScaleInfo *isi, int dh, con
int segments = (qsizetype(isi->sh) * isi->sw) / (1<<16);
segments = std::min(segments, dh);
QThreadPool *threadPool = QThreadPool::globalInstance();
- if (segments > 1 && !threadPool->contains(QThread::currentThread())) {
+ if (segments > 1 && threadPool && !threadPool->contains(QThread::currentThread())) {
QSemaphore semaphore;
int y = 0;
for (int i = 0; i < segments; ++i) {
diff --git a/src/gui/painting/qimagescale_sse4.cpp b/src/gui/painting/qimagescale_sse4.cpp
index 70cfa08d95..a5c9e68fad 100644
--- a/src/gui/painting/qimagescale_sse4.cpp
+++ b/src/gui/painting/qimagescale_sse4.cpp
@@ -60,7 +60,7 @@ static inline void multithread_pixels_function(QImageScaleInfo *isi, int dh, con
int segments = (qsizetype(isi->sh) * isi->sw) / (1<<16);
segments = std::min(segments, dh);
QThreadPool *threadPool = QThreadPool::globalInstance();
- if (segments > 1 && !threadPool->contains(QThread::currentThread())) {
+ if (segments > 1 && threadPool && !threadPool->contains(QThread::currentThread())) {
QSemaphore semaphore;
int y = 0;
for (int i = 0; i < segments; ++i) {