summaryrefslogtreecommitdiff
path: root/src/plugins/cmakeprojectmanager
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@qt.io>2018-06-29 13:24:36 +0200
committerTobias Hunger <tobias.hunger@qt.io>2018-06-29 13:42:41 +0000
commitf5d51dcb692648b0a9725fad286d535b694bb317 (patch)
treedf67ae4c98d473038c58a7b97c8447a30220bcd5 /src/plugins/cmakeprojectmanager
parentbe7109d73203b65b48f19d2eeb2561c3eb619101 (diff)
downloadqt-creator-f5d51dcb692648b0a9725fad286d535b694bb317.tar.gz
CMake: Simplify restoration of CMakeTools a bit
Change-Id: If62acc96bb64e8e0c2767e35d4f2bca43cc23c65 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Diffstat (limited to 'src/plugins/cmakeprojectmanager')
-rw-r--r--src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp b/src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp
index b116748fb0..2e6529ec08 100644
--- a/src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp
+++ b/src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp
@@ -321,25 +321,27 @@ void CMakeToolManager::restoreCMakeTools()
FileName sdkSettingsFile = FileName::fromString(ICore::installerResourcePath()
+ CMAKETOOL_FILENAME);
- QList<CMakeTool *> toolsToRegister = readCMakeTools(sdkSettingsFile, &defaultId, true);
+ QList<CMakeTool *> sdkTools = readCMakeTools(sdkSettingsFile, &defaultId, true);
//read the tools from the user settings file
- QList<CMakeTool *> readTools = readCMakeTools(userSettingsFileName(), &defaultId, false);
+ QList<CMakeTool *> userTools = readCMakeTools(userSettingsFileName(), &defaultId, false);
//autodetect tools
- QList<CMakeTool *> autoDetected = autoDetectCMakeTools();
+ QList<CMakeTool *> autoDetectedTools = autoDetectCMakeTools();
//filter out the tools that were stored in SDK
- for (int i = readTools.size() - 1; i >= 0; i--) {
- CMakeTool *currTool = readTools.takeAt(i);
- if (Utils::anyOf(toolsToRegister, Utils::equal(&CMakeTool::id, currTool->id()))) {
+ QList<CMakeTool *> toRegister;
+ for (int i = userTools.size() - 1; i >= 0; i--) {
+ CMakeTool *currTool = userTools.takeAt(i);
+ if (CMakeTool *sdk = Utils::findOrDefault(sdkTools, Utils::equal(&CMakeTool::id, currTool->id()))) {
delete currTool;
+ toRegister.append(sdk);
} else {
//if the current tool is marked as autodetected and NOT in the autodetected list,
//it is a leftover SDK provided tool. The user will not be able to edit it,
//so we automatically drop it
if (currTool->isAutoDetected()) {
- if (!Utils::anyOf(autoDetected,
+ if (!Utils::anyOf(autoDetectedTools,
Utils::equal(&CMakeTool::cmakeExecutable, currTool->cmakeExecutable()))) {
qWarning() << QString::fromLatin1("Previously SDK provided CMakeTool \"%1\" (%2) dropped.")
@@ -349,22 +351,22 @@ void CMakeToolManager::restoreCMakeTools()
continue;
}
}
- toolsToRegister.append(currTool);
+ toRegister.append(currTool);
}
}
//filter out the tools that are already known
- while (autoDetected.size()) {
- CMakeTool *currTool = autoDetected.takeFirst();
- if (Utils::anyOf(toolsToRegister,
+ while (autoDetectedTools.size()) {
+ CMakeTool *currTool = autoDetectedTools.takeFirst();
+ if (Utils::anyOf(toRegister,
Utils::equal(&CMakeTool::cmakeExecutable, currTool->cmakeExecutable())))
delete currTool;
else
- toolsToRegister.append(currTool);
+ toRegister.append(currTool);
}
// Store all tools
- foreach (CMakeTool *current, toolsToRegister) {
+ foreach (CMakeTool *current, toRegister) {
if (!registerCMakeTool(current)) {
//this should never happen, but lets make sure we do not leak memory
qWarning() << QString::fromLatin1("CMakeTool \"%1\" (%2) dropped.")