Q{Plugin,Factory}Loader: downgrade warnings to debug messages

Since we don't have different environment variables for the plugin paths,
users have to set QT_PLUGIN_PATH to where plugins for both Qt 5 and 6
(and future versions) are located. This causes Qt to print warnings that
those couldn't be loaded because the major version mismatches. So don't
print them any more.

QT_DEBUG_PLUGINS and the category logging filter can still be used to
enable them.

Fixes: QTBUG-107459
Change-Id: Idd5e1bb52be047d7b4fffffd175318ca1f8017bd
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
(cherry picked from commit 25e13c9079fbc441ecf37c8a601dd88cdebd0b49)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Thiago Macieira 2023-04-05 14:05:42 -03:00 committed by Qt Cherry-pick Bot
parent c26c0336b2
commit db0169bcd9
2 changed files with 2 additions and 6 deletions

View File

@ -258,7 +258,7 @@ static QLibraryScanResult findPatternUnloaded(const QString &library, QLibraryPr
#endif
if (!lib->metaData.parse(QByteArrayView(filedata + r.pos, r.length))) {
errMsg = lib->metaData.errorString();
qCWarning(qt_lcDebugPlugins, "Found invalid metadata in lib %ls: %ls",
qCDebug(qt_lcDebugPlugins, "Found invalid metadata in lib %ls: %ls",
qUtf16Printable(library), qUtf16Printable(errMsg));
} else {
qCDebug(qt_lcDebugPlugins, "Found metadata in lib %ls, metadata=\n%s\n",
@ -766,7 +766,7 @@ void QLibraryPrivate::updatePluginState()
uint qt_version = uint(metaData.value(QtPluginMetaDataKeys::QtVersion).toInteger());
bool debug = metaData.value(QtPluginMetaDataKeys::IsDebug).toBool();
if ((qt_version & 0x00ff00) > (QT_VERSION & 0x00ff00) || (qt_version & 0xff0000) != (QT_VERSION & 0xff0000)) {
qCWarning(qt_lcDebugPlugins, "In %s:\n"
qCDebug(qt_lcDebugPlugins, "In %s:\n"
" Plugin uses incompatible Qt library (%d.%d.%d) [%s]",
QFile::encodeName(fileName).constData(),
(qt_version&0xff0000) >> 16, (qt_version&0xff00) >> 8, qt_version&0xff,

View File

@ -224,10 +224,6 @@ void tst_QPlugin::scanInvalidPlugin()
// now try to load this
QFETCH(bool, loads);
QFETCH(QString, errMsg);
if (!errMsg.isEmpty())
QTest::ignoreMessage(QtWarningMsg,
"Found invalid metadata in lib " + QFile::encodeName(newName) +
":" + errMsg.toUtf8());
QPluginLoader loader(newName);
QCOMPARE(loader.load(), loads);
if (loads)