From 3340fa88e41b1ce764ff792f9272b4c462cd9bf2 Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Fri, 25 Jun 2021 18:10:45 +0200 Subject: [PATCH] CMakePM: Proper restore user saved CMake tools changes If you had an auto detected CMake tool from the sdk you would not be able to change the "Autorun CMake" state from ON to OFF because the sdk value would always be used instead of the user one. Fixes: QTCREATORBUG-25911 Change-Id: Ibe3b393a2b9e4d397251018fda8a9508ad096791 Reviewed-by: Qt CI Bot Reviewed-by: Eike Ziller --- .../cmakeprojectmanager/cmaketoolsettingsaccessor.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/plugins/cmakeprojectmanager/cmaketoolsettingsaccessor.cpp b/src/plugins/cmakeprojectmanager/cmaketoolsettingsaccessor.cpp index 0ebfb1fb365..b1dde077b67 100644 --- a/src/plugins/cmakeprojectmanager/cmaketoolsettingsaccessor.cpp +++ b/src/plugins/cmakeprojectmanager/cmaketoolsettingsaccessor.cpp @@ -128,7 +128,11 @@ mergeTools(std::vector> &sdkTools, std::unique_ptr userTool = std::move(userTools[0]); userTools.erase(std::begin(userTools)); - if (!Utils::contains(result, Utils::equal(&CMakeTool::id, userTool->id()))) { + int userToolIndex = Utils::indexOf(result, Utils::equal(&CMakeTool::id, userTool->id())); + if (userToolIndex >= 0) { + // Replace the sdk tool with the user tool, so any user changes do not get lost + result[userToolIndex] = std::move(userTool); + } else { if (userTool->isAutoDetected() && !Utils::contains(autoDetectedTools, Utils::equal(&CMakeTool::cmakeExecutable, userTool->cmakeExecutable()))) {