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>
This commit is contained in:
parent
c56e756aa9
commit
1767e21123
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user