aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@qt.io>2018-06-29 13:29:43 +0200
committerTobias Hunger <tobias.hunger@qt.io>2018-06-29 13:42:51 +0000
commit9c1fd4c2aa30344f837162c6dda5d125792319e0 (patch)
treecb3b585a639b59cea1ec62e4bd5511254fd088ad /src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp
parentf5d51dcb692648b0a9725fad286d535b694bb317 (diff)
CMake: Move CMakeTool merging into separate function
Change-Id: I7c70e0aa09def8c7483d183791a76e56be18a0a4 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Diffstat (limited to 'src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp')
-rw-r--r--src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp80
1 files changed, 44 insertions, 36 deletions
diff --git a/src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp b/src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp
index 2e6529ec08..0d58a6d9e2 100644
--- a/src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp
+++ b/src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp
@@ -190,6 +190,47 @@ static QList<CMakeTool *> autoDetectCMakeTools()
return found;
}
+static QList<CMakeTool *> mergeTools(QList<CMakeTool *> &sdkTools,
+ QList<CMakeTool *> &userTools,
+ QList<CMakeTool *> &autoDetectedTools)
+{
+ QList<CMakeTool *> result;
+ 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;
+ result.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(autoDetectedTools,
+ Utils::equal(&CMakeTool::cmakeExecutable, currTool->cmakeExecutable()))) {
+
+ qWarning() << QString::fromLatin1("Previously SDK provided CMakeTool \"%1\" (%2) dropped.")
+ .arg(currTool->cmakeExecutable().toUserOutput(), currTool->id().toString());
+
+ delete currTool;
+ continue;
+ }
+ }
+ result.append(currTool);
+ }
+ }
+
+ //filter out the tools that are already known
+ while (autoDetectedTools.size()) {
+ CMakeTool *currTool = autoDetectedTools.takeFirst();
+ if (Utils::anyOf(result,
+ Utils::equal(&CMakeTool::cmakeExecutable, currTool->cmakeExecutable())))
+ delete currTool;
+ else
+ result.append(currTool);
+ }
+ return result;
+}
+
// --------------------------------------------------------------------
// CMakeToolManager:
// --------------------------------------------------------------------
@@ -318,8 +359,8 @@ void CMakeToolManager::restoreCMakeTools()
{
Core::Id defaultId;
- FileName sdkSettingsFile = FileName::fromString(ICore::installerResourcePath()
- + CMAKETOOL_FILENAME);
+ const FileName sdkSettingsFile = FileName::fromString(ICore::installerResourcePath()
+ + CMAKETOOL_FILENAME);
QList<CMakeTool *> sdkTools = readCMakeTools(sdkSettingsFile, &defaultId, true);
@@ -330,40 +371,7 @@ void CMakeToolManager::restoreCMakeTools()
QList<CMakeTool *> autoDetectedTools = autoDetectCMakeTools();
//filter out the tools that were stored in SDK
- 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(autoDetectedTools,
- Utils::equal(&CMakeTool::cmakeExecutable, currTool->cmakeExecutable()))) {
-
- qWarning() << QString::fromLatin1("Previously SDK provided CMakeTool \"%1\" (%2) dropped.")
- .arg(currTool->cmakeExecutable().toUserOutput(), currTool->id().toString());
-
- delete currTool;
- continue;
- }
- }
- toRegister.append(currTool);
- }
- }
-
- //filter out the tools that are already known
- while (autoDetectedTools.size()) {
- CMakeTool *currTool = autoDetectedTools.takeFirst();
- if (Utils::anyOf(toRegister,
- Utils::equal(&CMakeTool::cmakeExecutable, currTool->cmakeExecutable())))
- delete currTool;
- else
- toRegister.append(currTool);
- }
+ const QList<CMakeTool *> toRegister = mergeTools(sdkTools, userTools, autoDetectedTools);
// Store all tools
foreach (CMakeTool *current, toRegister) {