1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

Fixes to remove duplicates and invalid CMake toolchain entries.

Change-Id: I1a8212945428b00d332b9f78c5a3eb81091f3fe6
This commit is contained in:
Doug Schaefer 2016-10-17 21:59:41 -04:00 committed by Gerrit Code Review @ Eclipse.org
parent 47784c8980
commit 5540c75ce0

View file

@ -7,6 +7,7 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.cmake.core.internal; package org.eclipse.cdt.cmake.core.internal;
import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.ArrayList; import java.util.ArrayList;
@ -54,15 +55,21 @@ public class CMakeToolChainManager implements ICMakeToolChainManager {
try { try {
for (String childName : prefs.childrenNames()) { for (String childName : prefs.childrenNames()) {
Preferences tcNode = prefs.node(childName); Preferences tcNode = prefs.node(childName);
String path = tcNode.get(PATH, "/"); //$NON-NLS-1$ String pathStr = tcNode.get(PATH, "/"); //$NON-NLS-1$
ICMakeToolChainFile file = new CMakeToolChainFile(childName, Paths.get(path)); Path path = Paths.get(pathStr);
for (String key : tcNode.keys()) { if (Files.exists(path) && !files.containsKey(path)) {
String value = tcNode.get(key, ""); //$NON-NLS-1$ ICMakeToolChainFile file = new CMakeToolChainFile(childName, path);
if (!value.isEmpty()) { for (String key : tcNode.keys()) {
file.setProperty(key, value); String value = tcNode.get(key, ""); //$NON-NLS-1$
if (!value.isEmpty()) {
file.setProperty(key, value);
}
} }
files.put(path, file);
} else {
tcNode.removeNode();
prefs.flush();
} }
files.put(file.getPath(), file);
} }
} catch (BackingStoreException e) { } catch (BackingStoreException e) {
Activator.log(e); Activator.log(e);
@ -93,6 +100,9 @@ public class CMakeToolChainManager implements ICMakeToolChainManager {
@Override @Override
public void addToolChainFile(ICMakeToolChainFile file) { public void addToolChainFile(ICMakeToolChainFile file) {
init(); init();
if (files.containsKey(file.getPath())) {
removeToolChainFile(file);
}
files.put(file.getPath(), file); files.put(file.getPath(), file);
// save it // save it