diff options
Diffstat (limited to 'src/gui/image')
-rw-r--r-- | src/gui/image/qpixmap.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index 674d5da..f823fdc 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -833,14 +833,21 @@ bool QPixmap::load(const QString &fileName, const char *format, Qt::ImageConvers if (QPixmapCache::find(key, *this)) return true; - QPixmapData *tmp = QPixmapData::create(0, 0, QPixmapData::PixmapType); - if (tmp->fromFile(fileName, format, flags)) { - data = tmp; - QPixmapCache::insert(key, *this); - return true; + bool ok; + + if (data) { + ok = data->fromFile(fileName, format, flags); + } else { + QScopedPointer<QPixmapData> tmp(QPixmapData::create(0, 0, QPixmapData::PixmapType)); + ok = tmp->fromFile(fileName, format, flags); + if (ok) + data = tmp.take(); } - delete tmp; - return false; + + if (ok) + QPixmapCache::insert(key, *this); + + return ok; } /*! |