From a1381dcce6ad42567d88d628934b55873c3687e9 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Fri, 20 Aug 2010 17:14:37 +0200 Subject: Revised fix for pixmap loading Change 2c8f9dee611 had an unwelcome side-effect and was reverted. Since we do have the undocumented behavior that we scan for all possible extensions when QPixmap is provided with a filename without extensions we could not simply exit if the file did not exist. We now check if there are extensions before doing so. Reviewed-by: gabi Task-number: QTBUG-11137 --- src/gui/image/qpixmap.cpp | 5 +++++ tests/auto/qpixmap/tst_qpixmap.cpp | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index 1c0ceff..c039ca8 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -836,6 +836,11 @@ bool QPixmap::load(const QString &fileName, const char *format, Qt::ImageConvers % HexString(info.size()) % HexString(data ? data->pixelType() : QPixmapData::PixmapType); + // Note: If no extension is provided, we try to match the + // file against known plugin extensions + if (!info.completeSuffix().isEmpty() && !info.exists()) + return false; + if (QPixmapCache::find(key, *this)) return true; diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp index e461b64..7e0f466 100644 --- a/tests/auto/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/qpixmap/tst_qpixmap.cpp @@ -1558,6 +1558,8 @@ void tst_QPixmap::loadFromDataImage_data() const QString prefix = QLatin1String(SRCDIR) + "/loadFromData"; #endif QTest::newRow("designer_argb32.png") << prefix + "/designer_argb32.png"; + // When no extension is provided we try all extensions that has been registered by image providers + QTest::newRow("designer_argb32") << prefix + "/designer_argb32.png"; QTest::newRow("designer_indexed8_no_alpha.png") << prefix + "/designer_indexed8_no_alpha.png"; QTest::newRow("designer_indexed8_with_alpha.png") << prefix + "/designer_indexed8_with_alpha.png"; QTest::newRow("designer_rgb32.png") << prefix + "/designer_rgb32.png"; -- cgit v0.12