QPlugin: add error messages to the qt_get_metadata()
This is the already-loaded counterpart to the file scanning code Change-Id: I3eb1bd30e0124f89a052fffd16a81f518fa95f0d Reviewed-by: Lars Knoll <lars.knoll@qt.io>bb10
parent
279176aa5d
commit
52377899d5
|
|
@ -676,19 +676,20 @@ bool QLibrary::isLibrary(const QString &fileName)
|
|||
|
||||
static bool qt_get_metadata(QLibraryPrivate *priv, QString *errMsg)
|
||||
{
|
||||
auto getMetaData = [](QFunctionPointer fptr) {
|
||||
auto f = reinterpret_cast<QPluginMetaData (*)()>(fptr);
|
||||
return f();
|
||||
auto error = [=](QString &&explanation) {
|
||||
*errMsg = QLibrary::tr("'%1' is not a Qt plugin (%2)").arg(priv->fileName, std::move(explanation));
|
||||
return false;
|
||||
};
|
||||
|
||||
QFunctionPointer pfn = priv->resolve("qt_plugin_query_metadata");
|
||||
if (!pfn)
|
||||
return false;
|
||||
return error(QLibrary::tr("entrypoint 'qt_plugin_query_metadata' not found"));
|
||||
|
||||
auto metaData = getMetaData(pfn);
|
||||
auto metaData = reinterpret_cast<QPluginMetaData (*)()>(pfn)();
|
||||
QJsonDocument doc = qJsonFromRawLibraryMetaData(reinterpret_cast<const char *>(metaData.data), metaData.size, errMsg);
|
||||
if (doc.isNull())
|
||||
return false;
|
||||
return false; // error message already set
|
||||
|
||||
priv->metaData = doc.object();
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue