summaryrefslogtreecommitdiffstats
path: root/src/gui/image/qpixmap.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2019-02-08 14:27:19 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2019-02-08 14:27:19 +0000
commit26ebdeff75d9f0f7b1ca2f82c35d7eaa013c0982 (patch)
tree88626bb5c88436b0e206907f15224bb035481f6b /src/gui/image/qpixmap.cpp
parent30178a22ffde5d216a350910668df0d906aced3b (diff)
parentfbfacd33be482fa3cf0aa5cffaf7006d538a2f92 (diff)
Merge "Merge remote-tracking branch 'origin/5.12' into 5.13" into refs/staging/5.13
Diffstat (limited to 'src/gui/image/qpixmap.cpp')
-rw-r--r--src/gui/image/qpixmap.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp
index 1ec4e3488a..2ef1d09422 100644
--- a/src/gui/image/qpixmap.cpp
+++ b/src/gui/image/qpixmap.cpp
@@ -714,8 +714,8 @@ QBitmap QPixmap::createMaskFromColor(const QColor &maskColor, Qt::MaskMode mode)
control the conversion.
Note that QPixmaps are automatically added to the QPixmapCache
- when loaded from a file; the key used is internal and can not
- be acquired.
+ when loaded from a file in main thread; the key used is internal
+ and cannot be acquired.
\sa loadFromData(), {QPixmap#Reading and Writing Image
Files}{Reading and Writing Image Files}
@@ -729,6 +729,7 @@ bool QPixmap::load(const QString &fileName, const char *format, Qt::ImageConvers
// Note: If no extension is provided, we try to match the
// file against known plugin extensions
if (info.completeSuffix().isEmpty() || info.exists()) {
+ const bool inGuiThread = qApp->thread() == QThread::currentThread();
QString key = QLatin1String("qt_pixmap")
% info.absoluteFilePath()
@@ -736,13 +737,14 @@ bool QPixmap::load(const QString &fileName, const char *format, Qt::ImageConvers
% HexString<quint64>(info.size())
% HexString<uint>(data ? data->pixelType() : QPlatformPixmap::PixmapType);
- if (QPixmapCache::find(key, this))
+ if (inGuiThread && QPixmapCache::find(key, this))
return true;
data = QPlatformPixmap::create(0, 0, data ? data->pixelType() : QPlatformPixmap::PixmapType);
if (data->fromFile(fileName, format, flags)) {
- QPixmapCache::insert(key, *this);
+ if (inGuiThread)
+ QPixmapCache::insert(key, *this);
return true;
}
}