summaryrefslogtreecommitdiffstats
path: root/src/gui/image/qimage_conversions.cpp
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 13:00:42 +0200
commit0aa8925f1acd47cadc71483cac97d202444d15db (patch)
tree9a1cf33b53877181956d440c7f3f78e48e6f897a /src/gui/image/qimage_conversions.cpp
parent1d778a59f781ecf822c9e3f7777b680fea2c4e62 (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 Pick-to: 5.15 Change-Id: I4105a68b6ae0637faf82cdda5f5ae44298759396 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'src/gui/image/qimage_conversions.cpp')
-rw-r--r--src/gui/image/qimage_conversions.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp
index 99a007ccaf..3f9eb08fdf 100644
--- a/src/gui/image/qimage_conversions.cpp
+++ b/src/gui/image/qimage_conversions.cpp
@@ -238,7 +238,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;
@@ -293,7 +293,7 @@ void convert_generic_over_rgb64(QImageData *dest, const QImageData *src, Qt::Ima
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) {
@@ -493,7 +493,7 @@ bool convert_generic_inplace_over_rgb64(QImageData *data, QImage::Format dst_for
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) {