diff options
author | Liang Qi <liang.qi@qt.io> | 2016-10-11 07:40:32 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-10-11 07:40:32 +0200 |
commit | 905329200f2f3f9372bf07a001371c30c0663684 (patch) | |
tree | e6f072ea693c377ae306b3960f4bde36ee20bc17 /src/gui/image/qpixmap.cpp | |
parent | 91cde062968f97041bca8d2a30d13aa03b606c3d (diff) | |
parent | 1a78ef09b93b0a7337075555dc91032f39fab2a9 (diff) |
Merge remote-tracking branch 'origin/5.7' into 5.8
Conflicts:
src/gui/image/qpixmap.cpp
src/widgets/kernel/qformlayout.cpp
Change-Id: I8a8391a202adf7f18464a22ddf0a6c4974eab692
Diffstat (limited to 'src/gui/image/qpixmap.cpp')
-rw-r--r-- | src/gui/image/qpixmap.cpp | 50 |
1 files changed, 24 insertions, 26 deletions
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index a360debf5b..0aa05a04e2 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -760,39 +760,37 @@ QBitmap QPixmap::createMaskFromColor(const QColor &maskColor, Qt::MaskMode mode) bool QPixmap::load(const QString &fileName, const char *format, Qt::ImageConversionFlags flags) { - if (fileName.isEmpty()) { - data.reset(); - return false; - } - - detach(); + if (!fileName.isEmpty()) { - QFileInfo info(fileName); - QString key = QLatin1String("qt_pixmap") - % info.absoluteFilePath() - % HexString<uint>(info.lastModified().toSecsSinceEpoch()) - % HexString<quint64>(info.size()) - % HexString<uint>(data ? data->pixelType() : QPlatformPixmap::PixmapType); + QFileInfo info(fileName); + // Note: If no extension is provided, we try to match the + // file against known plugin extensions + if (info.completeSuffix().isEmpty() || info.exists()) { - // Note: If no extension is provided, we try to match the - // file against known plugin extensions - if (!info.completeSuffix().isEmpty() && !info.exists()) { - data.reset(); - return false; - } + QString key = QLatin1String("qt_pixmap") + % info.absoluteFilePath() + % HexString<uint>(info.lastModified().toSecsSinceEpoch()) + % HexString<quint64>(info.size()) + % HexString<uint>(data ? data->pixelType() : QPlatformPixmap::PixmapType); - if (QPixmapCache::find(key, this)) - return true; + if (QPixmapCache::find(key, this)) + return true; - if (!data) - data = QPlatformPixmap::create(0, 0, QPlatformPixmap::PixmapType); + data = QPlatformPixmap::create(0, 0, data ? data->pixelType() : QPlatformPixmap::PixmapType); - if (data->fromFile(fileName, format, flags)) { - QPixmapCache::insert(key, *this); - return true; + if (data->fromFile(fileName, format, flags)) { + QPixmapCache::insert(key, *this); + return true; + } + } } - data.reset(); + if (!isNull()) { + if (isQBitmap()) + *this = QBitmap(); + else + data.reset(); + } return false; } |