diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index 2b148383b0..620cbde25d 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -51,6 +51,7 @@ #include "qvariant.h" #include "qcache.h" #include "qdebug.h" +#include "qdir.h" #include "qpalette.h" #include "qmath.h" @@ -1171,6 +1172,8 @@ QIcon QIcon::fromTheme(const QString &name) if (qtIconCache()->contains(name)) { icon = *qtIconCache()->object(name); + } else if (QDir::isAbsolutePath(name)) { + return QIcon(name); } else { QPlatformTheme * const platformTheme = QGuiApplicationPrivate::platformTheme(); bool hasUserTheme = QIconLoader::instance()->hasUserTheme(); diff --git a/tests/auto/gui/image/qicon/tst_qicon.cpp b/tests/auto/gui/image/qicon/tst_qicon.cpp index ff88b62c32..079b14a64e 100644 --- a/tests/auto/gui/image/qicon/tst_qicon.cpp +++ b/tests/auto/gui/image/qicon/tst_qicon.cpp @@ -642,6 +642,10 @@ void tst_QIcon::fromTheme() QIcon::setThemeName(""); abIcon = QIcon::fromTheme("address-book-new"); QVERIFY(abIcon.isNull()); + + // Passing a full path to fromTheme is not very useful, but should work anyway + QIcon fullPathIcon = QIcon::fromTheme(m_pngImageFileName); + QVERIFY(!fullPathIcon.isNull()); } void tst_QIcon::fromThemeCache()