From 46aecbd72b2e0630cc03bd51edf64179968902df Mon Sep 17 00:00:00 2001 From: Palo Kisa Date: Thu, 27 Apr 2017 10:03:53 +0200 Subject: [PATCH] QIconLoaderEngine: Fix actualSize() for no-entry Return an empty size if no suitable entry found to avoid mismatch with the returned pixmap()'s size (the QIconEngine::actualSize() returns the originally requested size). Change-Id: Ia278719a54392b62c5f9fc0529476baba5cd7df0 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/gui/image/qiconloader.cpp | 5 ++++- tests/auto/gui/image/qicon/tst_qicon.cpp | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp index d72c05a3c5..349e0dfbe3 100644 --- a/src/gui/image/qiconloader.cpp +++ b/src/gui/image/qiconloader.cpp @@ -649,6 +649,9 @@ QIconLoaderEngineEntry *QIconLoaderEngine::entryForSize(const QSize &size, int s QSize QIconLoaderEngine::actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state) { + Q_UNUSED(mode); + Q_UNUSED(state); + ensureLoaded(); QIconLoaderEngineEntry *entry = entryForSize(size); @@ -661,7 +664,7 @@ QSize QIconLoaderEngine::actualSize(const QSize &size, QIcon::Mode mode, return QSize(result, result); } } - return QIconEngine::actualSize(size, mode, state); + return QSize(0, 0); } QPixmap PixmapEntry::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) diff --git a/tests/auto/gui/image/qicon/tst_qicon.cpp b/tests/auto/gui/image/qicon/tst_qicon.cpp index d628fad705..e031ffec71 100644 --- a/tests/auto/gui/image/qicon/tst_qicon.cpp +++ b/tests/auto/gui/image/qicon/tst_qicon.cpp @@ -594,6 +594,7 @@ void tst_QIcon::fromTheme() QIcon noIcon = QIcon::fromTheme("broken-icon"); QVERIFY(noIcon.isNull()); QVERIFY(!QIcon::hasThemeIcon("broken-icon")); + QCOMPARE(noIcon.actualSize(QSize(32, 32), QIcon::Normal, QIcon::On), QSize(0, 0)); // Test non existing icon with fallback noIcon = QIcon::fromTheme("broken-icon", abIcon);