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 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'src/widgets/kernel/qicon.cpp') 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) { -- cgit v1.2.3