diff options
author | Kevin Ottens <ervin@kde.org> | 2013-03-22 08:47:51 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-04-22 20:19:28 +0200 |
commit | aa5f70c00a88edcddd26e8fea767a40e8c5c31b8 (patch) | |
tree | 84a5a691caabedc8f50d6190d494963469f9d698 /src | |
parent | ae0fd6884d30ae2ce084e239468696aaec7f5795 (diff) | |
download | qtbase-aa5f70c00a88edcddd26e8fea767a40e8c5c31b8.tar.gz |
Make sure QIconLoader is always initialized
It is necessary to properly initialize the icon loader in all case.
Otherwise some calls might give wrong results if a platform theme plugin
is involved.
For instance, we might miss the actual theme name reported by the
platform theme, eg it's what happen with QStyle::standardPixmap if no
one created a QIcon before its first call.
Also clean up the accesses to the global static and have only
QIconLoader::instance() use it. All other call go through the static
method. This way only instance() needs to call ensureInitialized(),
definitely safer and looks cleaner to me.
Change-Id: Id3ea6816edd5a65586004f69464960abc3602cf8
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/image/qicon.cpp | 1 | ||||
-rw-r--r-- | src/gui/image/qiconloader.cpp | 12 |
2 files changed, 5 insertions, 8 deletions
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index d73cd0aa57..ea35da54dc 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -1063,7 +1063,6 @@ void QIcon::setThemeName(const QString &name) */ QString QIcon::themeName() { - QIconLoader::instance()->ensureInitialized(); return QIconLoader::instance()->themeName(); } diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp index c2e5161bd3..6303f5cbe1 100644 --- a/src/gui/image/qiconloader.cpp +++ b/src/gui/image/qiconloader.cpp @@ -127,6 +127,7 @@ void QIconLoader::ensureInitialized() QIconLoader *QIconLoader::instance() { + iconLoaderInstance()->ensureInitialized(); return iconLoaderInstance(); } @@ -367,17 +368,14 @@ bool QIconLoaderEngine::hasIcon() const // Lazily load the icon void QIconLoaderEngine::ensureLoaded() { - - iconLoaderInstance()->ensureInitialized(); - - if (!(iconLoaderInstance()->themeKey() == m_key)) { + if (!(QIconLoader::instance()->themeKey() == m_key)) { while (!m_entries.isEmpty()) delete m_entries.takeLast(); Q_ASSERT(m_entries.size() == 0); - m_entries = iconLoaderInstance()->loadIcon(m_iconName); - m_key = iconLoaderInstance()->themeKey(); + m_entries = QIconLoader::instance()->loadIcon(m_iconName); + m_key = QIconLoader::instance()->themeKey(); } } @@ -564,7 +562,7 @@ void QIconLoaderEngine::virtual_hook(int id, void *data) { QIconEngine::AvailableSizesArgument &arg = *reinterpret_cast<QIconEngine::AvailableSizesArgument*>(data); - const QList<QIconDirInfo> directoryKey = iconLoaderInstance()->theme().keyList(); + const QList<QIconDirInfo> directoryKey = QIconLoader::instance()->theme().keyList(); arg.sizes.clear(); // Gets all sizes from the DirectoryInfo entries |