mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 18:26:01 +02:00
Fix for [Bug 157563] Close Project serializes the configurations of all projects in workspace
This commit is contained in:
parent
44e500cd01
commit
317bdea60e
2 changed files with 151 additions and 49 deletions
|
@ -775,6 +775,8 @@ public class CommonBuilder extends ACBuilder {
|
||||||
cfg.setRebuildState(true);
|
cfg.setRebuildState(true);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PropertyManager.getInstance().serialize(cfg);
|
||||||
} else if(status.getConsoleMessagesList().size() != 0) {
|
} else if(status.getConsoleMessagesList().size() != 0) {
|
||||||
emitMessage(bInfo, concatMessages(status.getConsoleMessagesList()));
|
emitMessage(bInfo, concatMessages(status.getConsoleMessagesList()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,10 +31,8 @@ import org.eclipse.cdt.managedbuilder.core.IToolChain;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.ProjectScope;
|
import org.eclipse.core.resources.ProjectScope;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.core.runtime.QualifiedName;
|
|
||||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||||
import org.osgi.service.prefs.BackingStoreException;
|
import org.osgi.service.prefs.BackingStoreException;
|
||||||
import org.osgi.service.prefs.Preferences;
|
import org.osgi.service.prefs.Preferences;
|
||||||
|
@ -44,13 +42,56 @@ import org.osgi.service.prefs.Preferences;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class PropertyManager {
|
public class PropertyManager {
|
||||||
private static final String PROPS_PROPERTY = "properties"; //$NON-NLS-1$
|
// private static final String PROPS_PROPERTY = "properties"; //$NON-NLS-1$
|
||||||
private static final QualifiedName propsSessionProperty = new QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(), PROPS_PROPERTY);
|
// private static final QualifiedName propsSessionProperty = new QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(), PROPS_PROPERTY);
|
||||||
|
|
||||||
private static final String NODE_NAME = "properties"; //$NON-NLS-1$
|
private static final String NODE_NAME = "properties"; //$NON-NLS-1$
|
||||||
|
|
||||||
private static PropertyManager fInstance;
|
private static PropertyManager fInstance;
|
||||||
|
|
||||||
|
private LoaddedInfo fLoaddedInfo;
|
||||||
|
|
||||||
|
private static class LoaddedInfo {
|
||||||
|
private final IProject fProject;
|
||||||
|
private final String fCfgId;
|
||||||
|
private final Map fCfgPropertyMap;
|
||||||
|
|
||||||
|
LoaddedInfo(IProject project, String cfgId, Map cfgPropertyMap){
|
||||||
|
fProject = project;
|
||||||
|
fCfgId = cfgId;
|
||||||
|
fCfgPropertyMap = cfgPropertyMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IConfiguration getConfiguration(){
|
||||||
|
return PropertyManager.getConfigurationFromId(fProject, fCfgId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IProject getProject(){
|
||||||
|
return fProject;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getConfigurationId(){
|
||||||
|
return fCfgId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map getProperties(){
|
||||||
|
return fCfgPropertyMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean cfgMatch(IConfiguration cfg){
|
||||||
|
if(fCfgId == null || fProject == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(!fCfgId.equals(cfg.getId()))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(!fProject.equals(PropertyManager.getProject(cfg)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private PropertyManager(){
|
private PropertyManager(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,35 +123,61 @@ public class PropertyManager {
|
||||||
return loadProperties(cfg, bo);
|
return loadProperties(cfg, bo);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Map getLoaddedData(IConfiguration cfg){
|
private LoaddedInfo getLoaddedInfo(){
|
||||||
Map map = null;
|
return fLoaddedInfo;
|
||||||
IProject proj = null;
|
|
||||||
try {
|
|
||||||
if(!((Configuration)cfg).isPreference()){
|
|
||||||
proj = cfg.getOwner().getProject();
|
|
||||||
map = (Map)proj.getSessionProperty(propsSessionProperty);
|
|
||||||
}
|
|
||||||
if(map == null){
|
|
||||||
map = new HashMap();
|
|
||||||
if(proj != null){
|
|
||||||
proj.setSessionProperty(propsSessionProperty, map);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
map = (Map)map.get(cfg.getId());
|
|
||||||
} catch (CoreException e) {
|
|
||||||
}
|
|
||||||
return map;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void clearLoaddedData(IConfiguration cfg){
|
private synchronized void setLoaddedInfo(LoaddedInfo info){
|
||||||
|
fLoaddedInfo = info;
|
||||||
|
}
|
||||||
|
protected Map getLoaddedData(IConfiguration cfg){
|
||||||
|
LoaddedInfo info = getLoaddedInfo();
|
||||||
|
if(info == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
if(!info.cfgMatch(cfg))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return info.getProperties();
|
||||||
|
// Map map = null;
|
||||||
|
// IProject proj = null;
|
||||||
|
// try {
|
||||||
|
// if(!((Configuration)cfg).isPreference()){
|
||||||
|
// proj = cfg.getOwner().getProject();
|
||||||
|
// map = (Map)proj.getSessionProperty(propsSessionProperty);
|
||||||
|
// }
|
||||||
|
// if(map == null){
|
||||||
|
// map = new HashMap();
|
||||||
|
// if(proj != null){
|
||||||
|
// proj.setSessionProperty(propsSessionProperty, map);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// map = (Map)map.get(cfg.getId());
|
||||||
|
// } catch (CoreException e) {
|
||||||
|
// }
|
||||||
|
// return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected synchronized void clearLoaddedData(IConfiguration cfg){
|
||||||
if(((Configuration)cfg).isPreference())
|
if(((Configuration)cfg).isPreference())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
IProject proj = cfg.getOwner().getProject();
|
LoaddedInfo info = getLoaddedInfo();
|
||||||
try {
|
if(info == null)
|
||||||
proj.setSessionProperty(propsSessionProperty, null);
|
return;
|
||||||
} catch (CoreException e) {
|
|
||||||
}
|
if(info.cfgMatch(cfg))
|
||||||
|
setLoaddedInfo(null);
|
||||||
|
// IProject proj = cfg.getOwner().getProject();
|
||||||
|
// try {
|
||||||
|
// proj.setSessionProperty(propsSessionProperty, null);
|
||||||
|
// } catch (CoreException e) {
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IProject getProject(IConfiguration cfg){
|
||||||
|
IResource rc = cfg.getOwner();
|
||||||
|
return rc != null ? rc.getProject() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Properties loadProperties(IConfiguration cfg, IBuildObject bo){
|
protected Properties loadProperties(IConfiguration cfg, IBuildObject bo){
|
||||||
|
@ -300,17 +367,43 @@ public class PropertyManager {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setLoaddedData(IConfiguration cfg, Map data){
|
private static IConfiguration getConfigurationFromId(IProject project, String id){
|
||||||
try {
|
if(project == null || id == null)
|
||||||
IProject proj = cfg.getOwner().getProject();
|
return null;
|
||||||
Map map = (Map)proj.getSessionProperty(propsSessionProperty);
|
IManagedBuildInfo bInfo = ManagedBuildManager.getBuildInfo(project, false);
|
||||||
if(map == null){
|
IConfiguration cfg = null;
|
||||||
map = new HashMap();
|
if(bInfo != null){
|
||||||
proj.setSessionProperty(propsSessionProperty, map);
|
IManagedProject mProj = bInfo.getManagedProject();
|
||||||
|
if(mProj != null){
|
||||||
|
cfg = mProj.getConfiguration(id);
|
||||||
}
|
}
|
||||||
map.put(cfg.getId(), data);
|
|
||||||
} catch (CoreException e) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return cfg;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setLoaddedData(IConfiguration cfg, Map data){
|
||||||
|
if(cfg.getOwner() == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
LoaddedInfo info = getLoaddedInfo();
|
||||||
|
|
||||||
|
if(info != null){
|
||||||
|
if(info.cfgMatch(cfg)){
|
||||||
|
info = new LoaddedInfo(info.getProject(), info.getConfigurationId(), data);
|
||||||
|
setLoaddedInfo(info);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
IConfiguration oldCfg = info.getConfiguration();
|
||||||
|
if(oldCfg != null){
|
||||||
|
storeData(oldCfg, info.getProperties());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IProject proj = cfg.getOwner().getProject();
|
||||||
|
info = new LoaddedInfo(proj, cfg.getId(), data);
|
||||||
|
setLoaddedInfo(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProperty(IConfiguration cfg, String key, String value){
|
public void setProperty(IConfiguration cfg, String key, String value){
|
||||||
|
@ -410,16 +503,23 @@ public class PropertyManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize(){
|
public void serialize(){
|
||||||
IProject projects[] = ResourcesPlugin.getWorkspace().getRoot().getProjects();
|
LoaddedInfo info = getLoaddedInfo();
|
||||||
for(int i = 0; i < projects.length; i++){
|
IConfiguration cfg = info.getConfiguration();
|
||||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(projects[i], false);
|
if(cfg != null){
|
||||||
if(info != null && info.isValid() && info.getManagedProject() != null){
|
serialize(cfg);
|
||||||
IConfiguration cfgs[] = info.getManagedProject().getConfigurations();
|
|
||||||
for(int j = 0; j < cfgs.length; j++){
|
clearLoaddedData(cfg);
|
||||||
serialize(cfgs[j]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// IProject projects[] = ResourcesPlugin.getWorkspace().getRoot().getProjects();
|
||||||
|
// for(int i = 0; i < projects.length; i++){
|
||||||
|
// IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(projects[i], false);
|
||||||
|
// if(info != null && info.isValid() && info.getManagedProject() != null){
|
||||||
|
// IConfiguration cfgs[] = info.getManagedProject().getConfigurations();
|
||||||
|
// for(int j = 0; j < cfgs.length; j++){
|
||||||
|
// serialize(cfgs[j]);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue