From a8f288fc9e752f34e8e3b732ced758074060c52d Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Mon, 8 May 2023 14:28:20 +0200 Subject: [PATCH] CMakePM: Store CMake Autorun state for all tools Amends 2f39b51bdc1f73e2d87cc641a8501fd04ee76b4f The default tool's value is taken as default global value, then will be saved for all tools. This fixes the case when the false Autorun value for the default CMake tool would always be set as global autorun with no option to actually set global Autorun value due to the "upgrade" path mechanism. Change-Id: I17076bc0c77b087c5d4048fdfe74ddf91d837fd4 Reviewed-by: Eike Ziller Reviewed-by: Qt CI Bot --- src/plugins/cmakeprojectmanager/cmaketool.h | 2 ++ src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp | 1 + .../cmakeprojectmanager/cmaketoolsettingsaccessor.cpp | 8 +++++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/plugins/cmakeprojectmanager/cmaketool.h b/src/plugins/cmakeprojectmanager/cmaketool.h index 42fa7b8f62d..54628910cc1 100644 --- a/src/plugins/cmakeprojectmanager/cmaketool.h +++ b/src/plugins/cmakeprojectmanager/cmaketool.h @@ -61,6 +61,8 @@ public: Utils::Id id() const { return m_id; } QVariantMap toMap () const; + void setAutorun(bool autoRun) { m_isAutoRun = autoRun; } + void setFilePath(const Utils::FilePath &executable); Utils::FilePath filePath() const; Utils::FilePath cmakeExecutable() const; diff --git a/src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp b/src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp index 8bc396ced1a..7e4c777317d 100644 --- a/src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp +++ b/src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp @@ -141,6 +141,7 @@ void CMakeToolManager::restoreCMakeTools() emit m_instance->cmakeToolsLoaded(); // Store the default CMake tool "Autorun CMake" value globally + // TODO: Remove in Qt Creator 13 auto settings = Internal::CMakeSpecificSettings::instance(); if (settings->autorunCMake.value() == settings->autorunCMake.defaultValue()) { CMakeTool *cmake = defaultCMakeTool(); diff --git a/src/plugins/cmakeprojectmanager/cmaketoolsettingsaccessor.cpp b/src/plugins/cmakeprojectmanager/cmaketoolsettingsaccessor.cpp index 43f1915709f..cfce81f005f 100644 --- a/src/plugins/cmakeprojectmanager/cmaketoolsettingsaccessor.cpp +++ b/src/plugins/cmakeprojectmanager/cmaketoolsettingsaccessor.cpp @@ -4,6 +4,7 @@ #include "cmaketoolsettingsaccessor.h" #include "cmakeprojectmanagertr.h" +#include "cmakespecificsettings.h" #include "cmaketool.h" #include @@ -185,9 +186,14 @@ void CMakeToolSettingsAccessor::saveCMakeTools(const QList &cmakeTo data.insert(QLatin1String(CMAKE_TOOL_DEFAULT_KEY), defaultId.toSetting()); int count = 0; - for (const CMakeTool *item : cmakeTools) { + for (CMakeTool *item : cmakeTools) { Utils::FilePath fi = item->cmakeExecutable(); + // Gobal Autorun value will be set for all tools + // TODO: Remove in Qt Creator 13 + const auto settings = CMakeSpecificSettings::instance(); + item->setAutorun(settings->autorunCMake.value()); + if (fi.needsDevice() || fi.isExecutableFile()) { // be graceful for device related stuff QVariantMap tmp = item->toMap(); if (tmp.isEmpty())