diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp index 142047e530..f83a9483f4 100644 --- a/src/corelib/plugin/qlibrary.cpp +++ b/src/corelib/plugin/qlibrary.cpp @@ -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(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(pfn)(); QJsonDocument doc = qJsonFromRawLibraryMetaData(reinterpret_cast(metaData.data), metaData.size, errMsg); if (doc.isNull()) - return false; + return false; // error message already set + priv->metaData = doc.object(); return true; }