Do not support static QIcon instances

There was an attempt to allow static instances of QIcon in
7727a4355876607a1a022ff54e2570dae883f79c (Qt 4). This patch does only
solve some of the corner cases and broke with
aa5f70c00a. Since the "breakage" has been
there for two years, let's officially declare it unsupported instead of
trying to work around the issue.

Change-Id: I61e12fd03953763ee2e70eae58bcaecabdcb85b8
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
bb10
Frederik Gladhorn 2015-07-09 09:34:32 +02:00
parent 130c2baa93
commit 8c7a9bfbbc
3 changed files with 2 additions and 11 deletions

View File

@ -595,6 +595,8 @@ QFactoryLoader *qt_iconEngineFactoryLoader()
\image icon.png QIcon
\note QIcon needs a QGuiApplication instance before the icon is created.
\sa {fowler}{GUI Design Handbook: Iconic Label}, {Icons Example}
*/
@ -1174,8 +1176,6 @@ QIcon QIcon::fromTheme(const QString &name, const QIcon &fallback)
qtIconCache()->insert(name, cachedIcon);
}
// Note the qapp check is to allow lazy loading of static icons
// Supporting fallbacks will not work for this case.
if (qApp && icon.availableSizes().isEmpty())
return fallback;

View File

@ -68,9 +68,6 @@ QIconLoader::QIconLoader() :
{
}
// We lazily initialize the loader to make static icons
// work. Though we do not officially support this.
static inline QString systemThemeName()
{
if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) {

View File

@ -75,14 +75,8 @@ private:
const QString m_pngImageFileName;
const QString m_pngRectFileName;
const QString m_sourceFileName;
const static QIcon staticIcon;
};
// Creating an icon statically should not cause a crash.
// But we do not officially support this. See QTBUG-8666
const QIcon tst_QIcon::staticIcon = QIcon::fromTheme("edit-find");
bool tst_QIcon::haveImageFormat(QByteArray const& desiredFormat)
{
return QImageReader::supportedImageFormats().contains(desiredFormat);