diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp index 629d59d535e..da02582338b 100644 --- a/src/gui/image/qiconloader.cpp +++ b/src/gui/image/qiconloader.cpp @@ -168,6 +168,7 @@ void QIconLoader::setFallbackThemeName(const QString &themeName) { qCDebug(lcIconLoader) << "Setting fallback theme name to" << themeName; m_userFallbackTheme = themeName; + invalidateKey(); } void QIconLoader::setThemeSearchPath(const QStringList &searchPaths) diff --git a/tests/auto/gui/image/qicon/CMakeLists.txt b/tests/auto/gui/image/qicon/CMakeLists.txt index c900c60d5b5..2d212defb78 100644 --- a/tests/auto/gui/image/qicon/CMakeLists.txt +++ b/tests/auto/gui/image/qicon/CMakeLists.txt @@ -56,6 +56,8 @@ set(tst_qicon_resource_files "./icons/themeparent/index.theme" "./icons/themeparent/scalable/actions/address-book-new.svg" "./icons/themeparent/scalable/actions/appointment-new.svg" + "./icons/fallbacktheme/index.theme" + "./icons/fallbacktheme/16x16/edit-cut.png" "./second_icons/testtheme/32x32/actions/appointment-new.png" "./styles/commonstyle/images/standardbutton-open-128.png" "./styles/commonstyle/images/standardbutton-open-16.png" diff --git a/tests/auto/gui/image/qicon/icons/fallbacktheme/16x16/edit-cut.png b/tests/auto/gui/image/qicon/icons/fallbacktheme/16x16/edit-cut.png new file mode 100644 index 00000000000..661ef1ad030 Binary files /dev/null and b/tests/auto/gui/image/qicon/icons/fallbacktheme/16x16/edit-cut.png differ diff --git a/tests/auto/gui/image/qicon/icons/fallbacktheme/index.theme b/tests/auto/gui/image/qicon/icons/fallbacktheme/index.theme new file mode 100644 index 00000000000..809d2966690 --- /dev/null +++ b/tests/auto/gui/image/qicon/icons/fallbacktheme/index.theme @@ -0,0 +1,8 @@ +[Icon Theme] +Name=fallbacktheme + +Directories=16x16 + +[16x16] +Size=16 +Type=Fixed diff --git a/tests/auto/gui/image/qicon/tst_qicon.cpp b/tests/auto/gui/image/qicon/tst_qicon.cpp index ebb0f1e9d2c..4b104490687 100644 --- a/tests/auto/gui/image/qicon/tst_qicon.cpp +++ b/tests/auto/gui/image/qicon/tst_qicon.cpp @@ -717,6 +717,11 @@ void tst_QIcon::fromTheme() QCOMPARE(i.availableSizes(), abIcon.availableSizes()); } + // Check that setting a fallback theme invalidates earlier lookups + QVERIFY(QIcon::fromTheme("edit-cut").isNull()); + QIcon::setFallbackThemeName("fallbacktheme"); + QVERIFY(!QIcon::fromTheme("edit-cut").isNull()); + // Make sure setting the theme name clears the state QIcon::setThemeName(""); abIcon = QIcon::fromTheme("address-book-new"); @@ -725,6 +730,9 @@ void tst_QIcon::fromTheme() // Passing a full path to fromTheme is not very useful, but should work anyway QIcon fullPathIcon = QIcon::fromTheme(m_pngImageFileName); QVERIFY(!fullPathIcon.isNull()); + + // Restore to system fallback theme + QIcon::setFallbackThemeName(""); } static inline QString findGtkUpdateIconCache()