From 4e4403d69c60ea6429b3ad5e7898a84b1dc92be5 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 8 May 2012 13:14:09 +0200 Subject: No longer use deprecated methods for plugin loading. Change-Id: I19c66b1c41ea4dd236726c86d7d071b210ec9244 Reviewed-by: Lars Knoll --- src/widgets/kernel/qicon.cpp | 28 ++++++++++++++++++---------- src/widgets/kernel/qiconloader.cpp | 2 +- src/widgets/styles/qstylefactory.cpp | 17 ++++++++++------- 3 files changed, 29 insertions(+), 18 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qicon.cpp b/src/widgets/kernel/qicon.cpp index 62c99a64c8..9c7f8736f0 100644 --- a/src/widgets/kernel/qicon.cpp +++ b/src/widgets/kernel/qicon.cpp @@ -816,10 +816,13 @@ void QIcon::addFile(const QString &fileName, const QSize &size, Mode mode, State QString suffix = info.suffix(); if (!suffix.isEmpty()) { // first try version 2 engines.. - if (QIconEngineFactoryInterface *factory = qobject_cast(loader()->instance(suffix))) { - if (QIconEngine *engine = factory->create(fileName)) { - d = new QIconPrivate; - d->engine = engine; + const int index = loader()->indexOf(suffix); + if (index != -1) { + if (QIconEngineFactoryInterface *factory = qobject_cast(loader()->instance(index))) { + if (QIconEngine *engine = factory->create(fileName)) { + d = new QIconPrivate; + d->engine = engine; + } } } } @@ -1068,12 +1071,17 @@ QDataStream &operator>>(QDataStream &s, QIcon &icon) icon.d->engine = engine; engine->read(s); #if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) - } else if (QIconEngineFactoryInterface *factory = qobject_cast(loader()->instance(key))) { - if (QIconEngine *engine= factory->create()) { - icon.d = new QIconPrivate; - icon.d->engine = engine; - engine->read(s); - } + } else { + const int index = loader()->indexOf(key); + if (index != -1) { + if (QIconEngineFactoryInterface *factory = qobject_cast(loader()->instance(index))) { + if (QIconEngine *engine= factory->create()) { + icon.d = new QIconPrivate; + icon.d->engine = engine; + engine->read(s); + } // factory + } // instance + } // index #endif } } else if (s.version() == QDataStream::Qt_4_2) { diff --git a/src/widgets/kernel/qiconloader.cpp b/src/widgets/kernel/qiconloader.cpp index 38cee3e51f..acbf7c1d07 100644 --- a/src/widgets/kernel/qiconloader.cpp +++ b/src/widgets/kernel/qiconloader.cpp @@ -121,7 +121,7 @@ void QIconLoader::ensureInitialized() QFactoryLoader iconFactoryLoader(QIconEngineFactoryInterface_iid, QLatin1String("/iconengines"), Qt::CaseInsensitive); - if (iconFactoryLoader.keys().contains(QLatin1String("svg"))) + if (iconFactoryLoader.keyMap().key(QLatin1String("svg"), -1) != -1) m_supportsSvg = true; #endif //QT_NO_LIBRARY } diff --git a/src/widgets/styles/qstylefactory.cpp b/src/widgets/styles/qstylefactory.cpp index 9ed452b516..ec29ae7b99 100644 --- a/src/widgets/styles/qstylefactory.cpp +++ b/src/widgets/styles/qstylefactory.cpp @@ -181,10 +181,8 @@ QStyle *QStyleFactory::create(const QString& key) #endif { } // Keep these here - they make the #ifdefery above work #if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) - if(!ret) { - if (QStyleFactoryInterface *factory = qobject_cast(loader()->instance(style))) - ret = factory->create(style); - } + if (!ret) + ret = qLoadPlugin(loader(), style); #endif if(ret) ret->setObjectName(style); @@ -199,10 +197,15 @@ QStyle *QStyleFactory::create(const QString& key) */ QStringList QStyleFactory::keys() { -#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) - QStringList list = loader()->keys(); -#else QStringList list; +#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) + typedef QMultiMap PluginKeyMap; + typedef PluginKeyMap::const_iterator PluginKeyMapConstIterator; + + const PluginKeyMap keyMap = loader()->keyMap(); + const PluginKeyMap::const_iterator cend = keyMap.constEnd(); + for (PluginKeyMap::const_iterator it = keyMap.constBegin(); it != cend; ++it) + list.append(it.value()); #endif #ifndef QT_NO_STYLE_WINDOWS if (!list.contains(QLatin1String("Windows"))) -- cgit v1.2.3