diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java index 39bb3f4eee6..25f5362a1ad 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java @@ -65,6 +65,7 @@ import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentBuildPathsChangeListene import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider; import org.eclipse.cdt.managedbuilder.internal.buildproperties.BuildPropertyManager; import org.eclipse.cdt.managedbuilder.internal.core.BooleanExpressionApplicabilityCalculator; +import org.eclipse.cdt.managedbuilder.internal.core.BuildSettingsUtil; import org.eclipse.cdt.managedbuilder.internal.core.Builder; import org.eclipse.cdt.managedbuilder.internal.core.BuilderFactory; import org.eclipse.cdt.managedbuilder.internal.core.CommonBuilder; @@ -1420,7 +1421,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI } // try { - CoreModel.getDefault().setProjectDescription(project, projDes); + BuildSettingsUtil.checkApplyDescription(project, projDes); // } catch (CoreException e) { // return false; // } @@ -1561,7 +1562,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI ICProjectDescription projDes = CoreModel.getDefault().getProjectDescription(project); if(projDes != null){ if(applyConfiguration(cfg, projDes, true)){ - CoreModel.getDefault().setProjectDescription(project, projDes); + BuildSettingsUtil.checkApplyDescription(project, projDes); } } } @@ -1584,8 +1585,9 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI updated = true; } } - if(updated) - CoreModel.getDefault().setProjectDescription(project, projDes); + if(updated){ + BuildSettingsUtil.checkApplyDescription(project, projDes); + } } } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuildSettingsUtil.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuildSettingsUtil.java index 96e3b97a064..0723f6e6427 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuildSettingsUtil.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuildSettingsUtil.java @@ -14,6 +14,9 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import org.eclipse.cdt.core.model.CoreModel; +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; +import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.managedbuilder.core.BuildException; import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IOption; @@ -22,6 +25,8 @@ import org.eclipse.cdt.managedbuilder.core.ITool; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin; import org.eclipse.cdt.managedbuilder.core.OptionStringValue; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; public class BuildSettingsUtil { private static final int[] COMMON_SETTINGS_IDS = new int[]{ @@ -133,4 +138,14 @@ public class BuildSettingsUtil { values.clear(); } } + + public static void checkApplyDescription(IProject project, ICProjectDescription des) throws CoreException{ + ICConfigurationDescription[] cfgs = des.getConfigurations(); + for(int i = 0; i < cfgs.length; i++){ + if(!ManagedBuildManager.CFG_DATA_PROVIDER_ID.equals(cfgs[i].getBuildSystemId())) + des.removeConfiguration(cfgs[i]); + } + + CoreModel.getDefault().setProjectDescription(project, des); + } } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java index 2ea3cf2a2d7..4228b34ecba 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java @@ -46,6 +46,7 @@ import org.eclipse.cdt.managedbuilder.core.ITarget; import org.eclipse.cdt.managedbuilder.core.ITool; import org.eclipse.cdt.managedbuilder.core.IToolChain; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; +import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin; import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable; import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider; import org.eclipse.cdt.managedbuilder.internal.macros.OptionContextData; @@ -260,12 +261,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo { } return defaultConfig; */ - ICProjectDescription des = CoreModel.getDefault().getProjectDescription(getOwner().getProject(), false); - IConfiguration activeCfg = null; - if(des != null){ - ICConfigurationDescription cfgDes = des.getActiveConfiguration(); - activeCfg = managedProject.getConfiguration(cfgDes.getId()); - } + IConfiguration activeCfg = findExistingDefaultConfiguration(); if(activeCfg == null){ IConfiguration cfgs[] = managedProject.getConfigurations(); @@ -276,6 +272,17 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo { return activeCfg; } + + private IConfiguration findExistingDefaultConfiguration() { + ICProjectDescription des = CoreModel.getDefault().getProjectDescription(getOwner().getProject(), false); + IConfiguration activeCfg = null; + if(des != null){ + ICConfigurationDescription cfgDes = des.getActiveConfiguration(); + activeCfg = managedProject.getConfiguration(cfgDes.getId()); + } + + return activeCfg; + } /* (non-Javadoc) * @see org.eclipse.cdt.core.build.managed.IScannerInfo#getDefinedSymbols() @@ -767,7 +774,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo { // Sanity if (configuration == null || configuration.isExtensionElement()) return; - if (!configuration.equals(getDefaultConfiguration())) { + if (!configuration.equals(findExistingDefaultConfiguration())) { IProject project = owner.getProject(); ICProjectDescription des = CoreModel.getDefault().getProjectDescription(project); if(des != null){ @@ -783,8 +790,9 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo { if(activeCfgDes != null){ des.setActiveConfiguration(activeCfgDes); try { - CoreModel.getDefault().setProjectDescription(project, des); + BuildSettingsUtil.checkApplyDescription(project, des); } catch (CoreException e) { + ManagedBuilderCorePlugin.log(e); } } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICConfigExtensionReference.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICConfigExtensionReference.java index bba7f827c97..22aa30c272c 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICConfigExtensionReference.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICConfigExtensionReference.java @@ -1,3 +1,13 @@ +/******************************************************************************* + * Copyright (c) 2007 Intel Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Intel Corporation - Initial API and implementation + *******************************************************************************/ package org.eclipse.cdt.core.settings.model; import org.eclipse.core.runtime.CoreException; diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationSpecSettings.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationSpecSettings.java index 58c63bf0df4..105689c4017 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationSpecSettings.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationSpecSettings.java @@ -919,6 +919,8 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{ Map.Entry entry = (Map.Entry)iter.next(); ICConfigExtensionReference[] thisRefs = (ICConfigExtensionReference[])entry.getValue(); ICConfigExtensionReference[] otherRefs = (ICConfigExtensionReference[])other.fExtMap.get(entry.getKey()); + if(otherRefs == null) + return thisRefs.length == 0; if(thisRefs.length != otherRefs.length) return false; diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescription.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescription.java index 915f877107c..54bd84dd0c4 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescription.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescription.java @@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.settings.model; import java.util.HashMap; import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.Map; import org.eclipse.cdt.core.CCorePlugin; @@ -45,7 +46,7 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon private IProject fProject; private ICSettingsStorage fStorage; private ICStorageElement fRootStorageElement; - private Map fCfgMap = new HashMap(); + private LinkedHashMap fCfgMap = new LinkedHashMap(); private boolean fIsReadOnly; private boolean fIsModified; private HashMap fPropertiesMap; @@ -234,6 +235,10 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon doneInitializing(); fIsLoadding = false; } + + void setLoadding(boolean loadding){ + fIsLoadding = loadding; + } private void doneInitializing(){ for(Iterator iter = fCfgMap.values().iterator(); iter.hasNext();){ diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java index 7ce9d4baa84..b3d53e55a76 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java @@ -380,10 +380,11 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { } } - private void clearDescriptionLoadding(IProject project){ + private CProjectDescription clearDescriptionLoadding(IProject project){ Map map = getDescriptionLoaddingMap(false); if(map != null) - map.remove(project); + return (CProjectDescription)map.remove(project); + return null; } private Map getDescriptionLoaddingMap(boolean create){ @@ -553,6 +554,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { ownerId = (String)info[0]; des = (CProjectDescription)info[1]; setDescriptionLoadding(project, des); + des.setLoadding(true); } else { ownerId = null; des = null; @@ -584,10 +586,13 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { } des = new CProjectDescription(des, true, el); - setDescriptionApplying(project, des); - des.applyDatas(); - des.doneApplying(); - clearDescriptionApplying(project); + try { + setDescriptionApplying(project, des); + des.applyDatas(); + des.doneApplying(); + } finally { + clearDescriptionApplying(project); + } try { ((InternalXmlStorageElement)des.getRootStorageElement()).setReadOnly(true); @@ -595,7 +600,9 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { } } }finally{ - clearDescriptionLoadding(project); + CProjectDescription d = clearDescriptionLoadding(project); + if(d != null) + d.setLoadding(false); } return des; }