From d6c95ef3655455a2b0b4c2c23d8dae1ab4ed1b78 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Mon, 2 Mar 2020 13:36:14 +0100 Subject: [PATCH] Take compatibility version into account for user plugins When loading user-local plugins, do not load plugins for all patch versions starting from .0 unconditionally. Take the compatibility version into account. That fixes that prereleases x.y.82 etc should not try loading plugins for any actual x.y.z release. Change-Id: Ide0931bbdef4f48e08dcc3213f7c193c8889fb0f Reviewed-by: Christian Kandeler --- src/app/app_version.h.cmakein | 1 + src/app/app_version.h.in | 3 +++ src/app/app_version_header.qbs | 2 ++ src/app/main.cpp | 5 ++++- 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/app/app_version.h.cmakein b/src/app/app_version.h.cmakein index 7fa0a830ddf..6d69f0d5dea 100644 --- a/src/app/app_version.h.cmakein +++ b/src/app/app_version.h.cmakein @@ -43,6 +43,7 @@ const char IDE_ID[] = "${IDE_ID}"; const char IDE_CASED_ID[] = "${IDE_CASED_ID}"; const char IDE_VERSION_DISPLAY[] = "${IDE_VERSION_DISPLAY}"; +const char IDE_VERSION_COMPAT[] = "${IDE_VERSION_COMPAT}"; const char IDE_REVISION_STR[] = "${IDE_REVISION_STR}"; const char IDE_REVISION_URL_STR[] = "${IDE_REVISION_URL_STR}"; diff --git a/src/app/app_version.h.in b/src/app/app_version.h.in index a3fc7f4b4ee..4682d282efb 100644 --- a/src/app/app_version.h.in +++ b/src/app/app_version.h.in @@ -38,6 +38,7 @@ const char IDE_CASED_ID[] = \"$${IDE_CASED_ID}\"; #define IDE_VERSION $${QTCREATOR_VERSION} #define IDE_VERSION_STR STRINGIFY(IDE_VERSION) #define IDE_VERSION_DISPLAY_DEF $${QTCREATOR_DISPLAY_VERSION} +#define IDE_VERSION_COMPAT_DEF $${QTCREATOR_COMPAT_VERSION} #define IDE_VERSION_MAJOR $$replace(QTCREATOR_VERSION, "^(\\d+)\\.\\d+\\.\\d+(-.*)?$", \\1) #define IDE_VERSION_MINOR $$replace(QTCREATOR_VERSION, "^\\d+\\.(\\d+)\\.\\d+(-.*)?$", \\1) @@ -45,6 +46,7 @@ const char IDE_CASED_ID[] = \"$${IDE_CASED_ID}\"; const char IDE_VERSION_LONG[] = IDE_VERSION_STR; const char IDE_VERSION_DISPLAY[] = STRINGIFY(IDE_VERSION_DISPLAY_DEF); +const char IDE_VERSION_COMPAT[] = STRINGIFY(IDE_VERSION_COMPAT_DEF); const char IDE_AUTHOR[] = \"The Qt Company Ltd\"; const char IDE_YEAR[] = \"$${QTCREATOR_COPYRIGHT_YEAR}\"; @@ -73,6 +75,7 @@ const char IDE_COPY_SETTINGS_FROM_VARIANT_STR[] = STRINGIFY(IDE_COPY_SETTINGS_FR const char IDE_COPY_SETTINGS_FROM_VARIANT_STR[] = \"\"; #endif +#undef IDE_VERSION_COMPAT_DEF #undef IDE_VERSION_DISPLAY_DEF #undef IDE_VERSION #undef IDE_VERSION_STR diff --git a/src/app/app_version_header.qbs b/src/app/app_version_header.qbs index 8bd2bc65bc3..4dd44c23851 100644 --- a/src/app/app_version_header.qbs +++ b/src/app/app_version_header.qbs @@ -34,6 +34,8 @@ Product { // replace the magic qmake incantations content = content.replace(/(\n#define IDE_VERSION_DISPLAY_DEF) .+\n/, "$1 " + product.moduleProperty("qtc", "qtcreator_display_version") + "\n"); + content = content.replace(/(\n#define IDE_VERSION_COMPAT_DEF) .+\n/, "$1 " + + product.moduleProperty("qtc", "qtcreator_compat_version") + "\n"); content = content.replace(/(\n#define IDE_VERSION) .+\n/, "$1 " + product.moduleProperty("qtc", "qtcreator_version") + "\n"); content = content.replace(/(\n#define IDE_VERSION_MAJOR) .+\n/, "$1 " diff --git a/src/app/main.cpp b/src/app/main.cpp index f2adb8b6206..cd566f218f6 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -237,7 +237,10 @@ static inline QStringList getPluginPaths() // patch versions const QString minorVersion = QString::number(IDE_VERSION_MAJOR) + '.' + QString::number(IDE_VERSION_MINOR) + '.'; - for (int patchVersion = IDE_VERSION_RELEASE; patchVersion >= 0; --patchVersion) + const int minPatchVersion + = qMin(IDE_VERSION_RELEASE, + QVersionNumber::fromString(Core::Constants::IDE_VERSION_COMPAT).microVersion()); + for (int patchVersion = IDE_VERSION_RELEASE; patchVersion >= minPatchVersion; --patchVersion) rc.push_back(pluginPath + minorVersion + QString::number(patchVersion)); return rc; }