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>bb10
parent
ae0fd6884d
commit
aa5f70c00a
|
|
@ -1063,7 +1063,6 @@ void QIcon::setThemeName(const QString &name)
|
|||
*/
|
||||
QString QIcon::themeName()
|
||||
{
|
||||
QIconLoader::instance()->ensureInitialized();
|
||||
return QIconLoader::instance()->themeName();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue