From dfe71d1d23746223b7bd047108850d07f8caa6e5 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 27 Sep 2024 13:56:26 +0200 Subject: [PATCH] Fix crash with KDE's platformtheme plugin Require QPA plugins to match qt major.minor rules Pick-to: 6.8 Change-Id: I78d40bb22d41b71db83c6a89c8ac8e319ec51d43 Reviewed-by: Thiago Macieira --- src/corelib/plugin/qfactoryloader.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp index ed7e398ea2c..c3c610ca5ef 100644 --- a/src/corelib/plugin/qfactoryloader.cpp +++ b/src/corelib/plugin/qfactoryloader.cpp @@ -348,6 +348,14 @@ inline void QFactoryLoaderPrivate::updateSinglePath(const QString &path) if (!metaDataOk) continue; + static constexpr qint64 QtVersionNoPatch = QT_VERSION_CHECK(QT_VERSION_MAJOR, QT_VERSION_MINOR, 0); + int thisVersion = library->metaData.value(QtPluginMetaDataKeys::QtVersion).toInteger(); + if (iid.startsWith(QStringLiteral("org.qt-project.Qt.QPA"))) { + // QPA plugins must match Qt Major.Minor + if (thisVersion != QtVersionNoPatch) + continue; + } + int keyUsageCount = 0; for (const QString &key : std::as_const(keys)) { QLibraryPrivate *&keyMapEntry = keyMap[key]; @@ -363,9 +371,7 @@ inline void QFactoryLoaderPrivate::updateSinglePath(const QString &path) // If the existing library was built with a future Qt version, // whereas the one we're considering has a Qt version that fits // better, we prioritize the better match. - static constexpr qint64 QtVersionNoPatch = QT_VERSION_CHECK(QT_VERSION_MAJOR, QT_VERSION_MINOR, 0); int existingVersion = existingLibrary->metaData.value(QtPluginMetaDataKeys::QtVersion).toInteger(); - int thisVersion = library->metaData.value(QtPluginMetaDataKeys::QtVersion).toInteger(); if (!(existingVersion > QtVersionNoPatch && thisVersion <= QtVersionNoPatch)) continue; // Existing version is a better match }