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:
parent
9baf7bad59
commit
46aecbd72b
@ -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)
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user