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:
Thiago Macieira 2012-07-09 13:46:48 +02:00 committed by Qt by Nokia
parent 282d81e4e5
commit 0aa4fa455e

View File

@ -217,8 +217,7 @@ QList<QJsonObject> QFactoryLoader::metaData() const
if (object.value(QLatin1String("IID")) != QLatin1String(d->iid.constData(), d->iid.size()))
continue;
QJsonObject meta = object.value(QLatin1String("MetaData")).toObject();
metaData.append(meta);
metaData.append(object);
}
return metaData;
}
@ -246,8 +245,16 @@ QObject *QFactoryLoader::instance(int index) const
index -= d->libraryList.size();
QVector<QStaticPlugin> staticPlugins = QLibraryPrivate::staticPlugins();
if (index < staticPlugins.size())
return staticPlugins.at(index).instance();
for (int i = 0; i < staticPlugins.count(); ++i) {
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;
}