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 <qt_ci_bot@qt-project.org>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Cristian Adam
2021-06-25 18:10:45 +02:00
parent fc493c3fcb
commit 3340fa88e4

View File

@@ -128,7 +128,11 @@ mergeTools(std::vector<std::unique_ptr<CMakeTool>> &sdkTools,
std::unique_ptr<CMakeTool> userTool = std::move(userTools[0]); std::unique_ptr<CMakeTool> userTool = std::move(userTools[0]);
userTools.erase(std::begin(userTools)); 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() if (userTool->isAutoDetected()
&& !Utils::contains(autoDetectedTools, Utils::equal(&CMakeTool::cmakeExecutable, && !Utils::contains(autoDetectedTools, Utils::equal(&CMakeTool::cmakeExecutable,
userTool->cmakeExecutable()))) { userTool->cmakeExecutable()))) {