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) <ogoffart@woboq.com>
This commit is contained in:
Palo Kisa 2017-04-27 10:03:53 +02:00
parent 9baf7bad59
commit 46aecbd72b
2 changed files with 5 additions and 1 deletions

View File

@ -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)

View File

@ -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);