forked from qt-creator/qt-creator
CMake: Simplify restoration of CMakeTools a bit
Change-Id: If62acc96bb64e8e0c2767e35d4f2bca43cc23c65 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -321,25 +321,27 @@ void CMakeToolManager::restoreCMakeTools()
|
|||||||
FileName sdkSettingsFile = FileName::fromString(ICore::installerResourcePath()
|
FileName sdkSettingsFile = FileName::fromString(ICore::installerResourcePath()
|
||||||
+ CMAKETOOL_FILENAME);
|
+ CMAKETOOL_FILENAME);
|
||||||
|
|
||||||
QList<CMakeTool *> toolsToRegister = readCMakeTools(sdkSettingsFile, &defaultId, true);
|
QList<CMakeTool *> sdkTools = readCMakeTools(sdkSettingsFile, &defaultId, true);
|
||||||
|
|
||||||
//read the tools from the user settings file
|
//read the tools from the user settings file
|
||||||
QList<CMakeTool *> readTools = readCMakeTools(userSettingsFileName(), &defaultId, false);
|
QList<CMakeTool *> userTools = readCMakeTools(userSettingsFileName(), &defaultId, false);
|
||||||
|
|
||||||
//autodetect tools
|
//autodetect tools
|
||||||
QList<CMakeTool *> autoDetected = autoDetectCMakeTools();
|
QList<CMakeTool *> autoDetectedTools = autoDetectCMakeTools();
|
||||||
|
|
||||||
//filter out the tools that were stored in SDK
|
//filter out the tools that were stored in SDK
|
||||||
for (int i = readTools.size() - 1; i >= 0; i--) {
|
QList<CMakeTool *> toRegister;
|
||||||
CMakeTool *currTool = readTools.takeAt(i);
|
for (int i = userTools.size() - 1; i >= 0; i--) {
|
||||||
if (Utils::anyOf(toolsToRegister, Utils::equal(&CMakeTool::id, currTool->id()))) {
|
CMakeTool *currTool = userTools.takeAt(i);
|
||||||
|
if (CMakeTool *sdk = Utils::findOrDefault(sdkTools, Utils::equal(&CMakeTool::id, currTool->id()))) {
|
||||||
delete currTool;
|
delete currTool;
|
||||||
|
toRegister.append(sdk);
|
||||||
} else {
|
} else {
|
||||||
//if the current tool is marked as autodetected and NOT in the autodetected list,
|
//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,
|
//it is a leftover SDK provided tool. The user will not be able to edit it,
|
||||||
//so we automatically drop it
|
//so we automatically drop it
|
||||||
if (currTool->isAutoDetected()) {
|
if (currTool->isAutoDetected()) {
|
||||||
if (!Utils::anyOf(autoDetected,
|
if (!Utils::anyOf(autoDetectedTools,
|
||||||
Utils::equal(&CMakeTool::cmakeExecutable, currTool->cmakeExecutable()))) {
|
Utils::equal(&CMakeTool::cmakeExecutable, currTool->cmakeExecutable()))) {
|
||||||
|
|
||||||
qWarning() << QString::fromLatin1("Previously SDK provided CMakeTool \"%1\" (%2) dropped.")
|
qWarning() << QString::fromLatin1("Previously SDK provided CMakeTool \"%1\" (%2) dropped.")
|
||||||
@@ -349,22 +351,22 @@ void CMakeToolManager::restoreCMakeTools()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
toolsToRegister.append(currTool);
|
toRegister.append(currTool);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//filter out the tools that are already known
|
//filter out the tools that are already known
|
||||||
while (autoDetected.size()) {
|
while (autoDetectedTools.size()) {
|
||||||
CMakeTool *currTool = autoDetected.takeFirst();
|
CMakeTool *currTool = autoDetectedTools.takeFirst();
|
||||||
if (Utils::anyOf(toolsToRegister,
|
if (Utils::anyOf(toRegister,
|
||||||
Utils::equal(&CMakeTool::cmakeExecutable, currTool->cmakeExecutable())))
|
Utils::equal(&CMakeTool::cmakeExecutable, currTool->cmakeExecutable())))
|
||||||
delete currTool;
|
delete currTool;
|
||||||
else
|
else
|
||||||
toolsToRegister.append(currTool);
|
toRegister.append(currTool);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store all tools
|
// Store all tools
|
||||||
foreach (CMakeTool *current, toolsToRegister) {
|
foreach (CMakeTool *current, toRegister) {
|
||||||
if (!registerCMakeTool(current)) {
|
if (!registerCMakeTool(current)) {
|
||||||
//this should never happen, but lets make sure we do not leak memory
|
//this should never happen, but lets make sure we do not leak memory
|
||||||
qWarning() << QString::fromLatin1("CMakeTool \"%1\" (%2) dropped.")
|
qWarning() << QString::fromLatin1("CMakeTool \"%1\" (%2) dropped.")
|
||||||
|
Reference in New Issue
Block a user