summaryrefslogtreecommitdiffstats
path: root/src/gui/image/qpixmap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/image/qpixmap.cpp')
-rw-r--r--src/gui/image/qpixmap.cpp50
1 files changed, 24 insertions, 26 deletions
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp
index 78031bca97..3726b2124c 100644
--- a/src/gui/image/qpixmap.cpp
+++ b/src/gui/image/qpixmap.cpp
@@ -762,39 +762,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().toTime_t())
- % 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().toTime_t())
+ % 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;
}