Fix static plugin loading.
The QFactoryLoader::indexOf and keyMap functions expect to receive the metadata that contains a "MetaData" entry, instead of the entry itself. Also, QFactoryLoader::metaData() skips static plugins with the wrong IID, so we need to skip it too in QFactoryLoader::instance(). Change-Id: I8a453087feb88d0e8d1021054353f3600d5100a5 Reviewed-by: Mark Brand <mabrand@mabrand.nl>
This commit is contained in:
parent
282d81e4e5
commit
0aa4fa455e
@ -217,8 +217,7 @@ QList<QJsonObject> QFactoryLoader::metaData() const
|
|||||||
if (object.value(QLatin1String("IID")) != QLatin1String(d->iid.constData(), d->iid.size()))
|
if (object.value(QLatin1String("IID")) != QLatin1String(d->iid.constData(), d->iid.size()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
QJsonObject meta = object.value(QLatin1String("MetaData")).toObject();
|
metaData.append(object);
|
||||||
metaData.append(meta);
|
|
||||||
}
|
}
|
||||||
return metaData;
|
return metaData;
|
||||||
}
|
}
|
||||||
@ -246,8 +245,16 @@ QObject *QFactoryLoader::instance(int index) const
|
|||||||
|
|
||||||
index -= d->libraryList.size();
|
index -= d->libraryList.size();
|
||||||
QVector<QStaticPlugin> staticPlugins = QLibraryPrivate::staticPlugins();
|
QVector<QStaticPlugin> staticPlugins = QLibraryPrivate::staticPlugins();
|
||||||
if (index < staticPlugins.size())
|
for (int i = 0; i < staticPlugins.count(); ++i) {
|
||||||
return staticPlugins.at(index).instance();
|
const char *rawMetaData = staticPlugins.at(i).metaData();
|
||||||
|
QJsonObject object = QLibraryPrivate::fromRawMetaData(rawMetaData).object();
|
||||||
|
if (object.value(QLatin1String("IID")) != QLatin1String(d->iid.constData(), d->iid.size()))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (index == 0)
|
||||||
|
return staticPlugins.at(i).instance();
|
||||||
|
--index;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user