summaryrefslogtreecommitdiffstats
path: root/src/corelib/plugin
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2012-04-30 12:31:48 +0200
committerQt by Nokia <qt-info@nokia.com>2012-05-01 07:10:37 +0200
commit1767e21123a6b3d9bfa71027ad42cb16b43f7b4f (patch)
treef7a462671e40910a90ceda62f0ecad9a1eb74365 /src/corelib/plugin
parentc56e756aa9d58c6ebce9df2fb4f41ba94afc5b57 (diff)
Allow loading of static plugins by index
Static plugins could so far not get loaded by index. Implement the missing support for this. Task-number: QTBUG-25274 Change-Id: I901b08bfaf4f9fc3cb9fcea0b47f3ed89588a27b Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/plugin')
-rw-r--r--src/corelib/plugin/qfactoryloader.cpp29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp
index 3f192ea477..fc9e94037f 100644
--- a/src/corelib/plugin/qfactoryloader.cpp
+++ b/src/corelib/plugin/qfactoryloader.cpp
@@ -326,20 +326,29 @@ QObject *QFactoryLoader::instance(const QString &key) const
QObject *QFactoryLoader::instance(int index) const
{
Q_D(const QFactoryLoader);
- if (index < 0 || index >= d->libraryList.size())
+ if (index < 0)
return 0;
- QLibraryPrivate *library = d->libraryList.at(index);
- if (library->instance || library->loadPlugin()) {
- if (!library->inst)
- library->inst = library->instance();
- QObject *obj = library->inst.data();
- if (obj) {
- if (!obj->parent())
- obj->moveToThread(QCoreApplicationPrivate::mainThread());
- return obj;
+ if (index < d->libraryList.size()) {
+ QLibraryPrivate *library = d->libraryList.at(index);
+ if (library->instance || library->loadPlugin()) {
+ if (!library->inst)
+ library->inst = library->instance();
+ QObject *obj = library->inst.data();
+ if (obj) {
+ if (!obj->parent())
+ obj->moveToThread(QCoreApplicationPrivate::mainThread());
+ return obj;
+ }
}
+ return 0;
}
+
+ index -= d->libraryList.size();
+ QVector<QStaticPlugin> staticPlugins = QLibraryPrivate::staticPlugins();
+ if (index < staticPlugins.size())
+ return staticPlugins.at(index).instance();
+
return 0;
}