mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-21 07:55:24 +02:00
Bug 318600 - referenced configuration settings can disappear as a result of reconcile during load
This commit is contained in:
parent
a529a397d0
commit
f7156a727c
2 changed files with 28 additions and 11 deletions
|
@ -669,11 +669,13 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP
|
||||||
|
|
||||||
CExternalSetting[] newSettings = null;
|
CExternalSetting[] newSettings = null;
|
||||||
CExternalSetting[] oldSettings = hCr.getHolder(false).getExternalSettings();
|
CExternalSetting[] oldSettings = hCr.getHolder(false).getExternalSettings();
|
||||||
if (op != OP_REMOVED) {
|
|
||||||
FactoryDescriptor dr = getFactoryDescriptor(cr.getFactoryId());
|
// ensure that the configuration exported external settings are cached even if this is a REMOVE operation
|
||||||
ContainerDescriptor cdr = new ContainerDescriptor(dr, cr.getContainerId(), proj, cfgDes, oldSettings);
|
FactoryDescriptor dr = getFactoryDescriptor(cr.getFactoryId());
|
||||||
newSettings = cdr.getExternalSettings();
|
ContainerDescriptor cdr = new ContainerDescriptor(dr, cr.getContainerId(), proj, cfgDes, oldSettings);
|
||||||
}
|
newSettings = cdr.getExternalSettings();
|
||||||
|
if (op == OP_REMOVED)
|
||||||
|
newSettings = null;
|
||||||
|
|
||||||
ExtSettingsDelta[] deltas = CExternalSettinsDeltaCalculator.getInstance().getSettingChange(newSettings, oldSettings);
|
ExtSettingsDelta[] deltas = CExternalSettinsDeltaCalculator.getInstance().getSettingChange(newSettings, oldSettings);
|
||||||
if(deltas != null) {
|
if(deltas != null) {
|
||||||
|
|
|
@ -17,6 +17,7 @@ import java.util.Iterator;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.settings.model.CExternalSetting;
|
import org.eclipse.cdt.core.settings.model.CExternalSetting;
|
||||||
|
@ -49,6 +50,9 @@ public class CfgExportSettingContainerFactory extends
|
||||||
private static final String ACTIVE_CONFIG_ID = ""; //$NON-NLS-1$
|
private static final String ACTIVE_CONFIG_ID = ""; //$NON-NLS-1$
|
||||||
private static final char DELIMITER = ';';
|
private static final char DELIMITER = ';';
|
||||||
|
|
||||||
|
/** Cache the external settings exported by project configurations */
|
||||||
|
private static final ConcurrentHashMap<String, CExternalSetting[]> cachedSettings = new ConcurrentHashMap<String, CExternalSetting[]>();
|
||||||
|
|
||||||
private static CfgExportSettingContainerFactory fInstance;
|
private static CfgExportSettingContainerFactory fInstance;
|
||||||
|
|
||||||
private CfgExportSettingContainerFactory(){
|
private CfgExportSettingContainerFactory(){
|
||||||
|
@ -77,10 +81,12 @@ public class CfgExportSettingContainerFactory extends
|
||||||
* exported by a referenced configuration in another project.
|
* exported by a referenced configuration in another project.
|
||||||
*/
|
*/
|
||||||
private static class CfgRefContainer extends CExternalSettingsContainer {
|
private static class CfgRefContainer extends CExternalSettingsContainer {
|
||||||
|
final private String fId;
|
||||||
final private String fProjName, fCfgId;
|
final private String fProjName, fCfgId;
|
||||||
final private CExternalSetting[] prevSettings;
|
final private CExternalSetting[] prevSettings;
|
||||||
|
|
||||||
CfgRefContainer(String projName, String cfgId, CExternalSetting[] previousSettings){
|
CfgRefContainer(String containerId, String projName, String cfgId, CExternalSetting[] previousSettings){
|
||||||
|
fId = containerId;
|
||||||
fProjName = projName;
|
fProjName = projName;
|
||||||
fCfgId = cfgId;
|
fCfgId = cfgId;
|
||||||
prevSettings = previousSettings;
|
prevSettings = previousSettings;
|
||||||
|
@ -96,17 +102,26 @@ public class CfgExportSettingContainerFactory extends
|
||||||
des.getConfigurationById(fCfgId) : des.getActiveConfiguration();
|
des.getConfigurationById(fCfgId) : des.getActiveConfiguration();
|
||||||
|
|
||||||
if(cfg != null){
|
if(cfg != null){
|
||||||
|
CExternalSetting[] es;
|
||||||
ICExternalSetting[] ies = cfg.getExternalSettings();
|
ICExternalSetting[] ies = cfg.getExternalSettings();
|
||||||
if(ies instanceof CExternalSetting[])
|
if (ies instanceof CExternalSetting[])
|
||||||
return (CExternalSetting[])ies;
|
es = (CExternalSetting[])ies;
|
||||||
CExternalSetting[] es = new CExternalSetting[ies.length];
|
else {
|
||||||
System.arraycopy(ies, 0, es, 0, es.length);
|
es = new CExternalSetting[ies.length];
|
||||||
|
System.arraycopy(ies, 0, es, 0, es.length);
|
||||||
|
}
|
||||||
|
// Update the cache with the real settings this configuration is exporting
|
||||||
|
cachedSettings.put(fId, es);
|
||||||
return es;
|
return es;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If project not yet accessible, just return the previous settings
|
// If project not yet accessible, just return the previous settings
|
||||||
// for the moment. We'll update again when the referenced project reappears
|
// for the moment. We'll update again when the referenced project reappears
|
||||||
|
if (!cachedSettings.containsKey(fId) && prevSettings.length > 0)
|
||||||
|
cachedSettings.putIfAbsent(fId, prevSettings);
|
||||||
|
if (prevSettings.length == 0 && cachedSettings.containsKey(fId))
|
||||||
|
return cachedSettings.get(fId);
|
||||||
return prevSettings;
|
return prevSettings;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,7 +130,7 @@ public class CfgExportSettingContainerFactory extends
|
||||||
public CExternalSettingsContainer createContainer(String id,
|
public CExternalSettingsContainer createContainer(String id,
|
||||||
IProject project, ICConfigurationDescription cfgDes, CExternalSetting[] previousSettings) throws CoreException {
|
IProject project, ICConfigurationDescription cfgDes, CExternalSetting[] previousSettings) throws CoreException {
|
||||||
String[] r = parseId(id);
|
String[] r = parseId(id);
|
||||||
return new CfgRefContainer(r[0], r[1], previousSettings);
|
return new CfgRefContainer(id, r[0], r[1], previousSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void createReference(ICConfigurationDescription cfg, String projName, String cfgId){
|
private static void createReference(ICConfigurationDescription cfg, String projName, String cfgId){
|
||||||
|
|
Loading…
Add table
Reference in a new issue