1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

bug 340219: Project metadata files are saved unnecessarily, patch to

address .cproject file modifications
This commit is contained in:
Baltasar Belyavsky 2012-02-11 08:29:43 -05:00 committed by Andrew Gvozdev
parent 6b66aef60b
commit 88bf01e541
2 changed files with 25 additions and 25 deletions

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2010 Intel Corporation and others.
* Copyright (c) 2007, 2012 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
@ -8,6 +8,7 @@
* Contributors:
* Intel Corporation - Initial API and implementation
* James Blackburn (Broadcom Corp.)
* Baltasar Belyavsky (Texas Instruments) - bug 340219: Project metadata files are saved unnecessarily
*******************************************************************************/
package org.eclipse.cdt.internal.core.settings.model;
@ -50,7 +51,6 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
private boolean fIsReadOnly;
private boolean fIsModified;
private HashMap<QualifiedName, Object> fPropertiesMap;
// private boolean fNeedsActiveCfgIdPersistence;
private boolean fIsLoading;
private boolean fIsApplying;
private boolean fIsCreating;
@ -549,17 +549,10 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
return cfg;
}
@Override
public boolean isModified() {
boolean needsDescriptionPersistence() {
if(fIsModified)
return true;
if(fActiveCfgInfo.fIsCfgModified)
return true;
if(fSettingCfgInfo.fIsCfgModified)
return true;
if(fPrefs.isModified())
return true;
@ -573,6 +566,20 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
return false;
}
@Override
public boolean isModified() {
if(needsDescriptionPersistence())
return true;
if(needsActiveCfgPersistence())
return true;
if(needsSettingCfgPersistence())
return true;
return false;
}
private void setModified(boolean modified){
fIsModified = modified;
@ -665,13 +672,6 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
}
}
// boolean checkPersistCfgChanges(boolean force){
// boolean stored = false;
// stored |= checkPersistActiveCfg(force);
// stored |= checkPersistSettingCfg(force);
// return stored;
// }
boolean checkPersistActiveCfg(String oldId, boolean force){
return fActiveCfgInfo.store(oldId, force);
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2010 Intel Corporation and others.
* Copyright (c) 2007, 2012 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
@ -8,6 +8,7 @@
* Contributors:
* Intel Corporation - Initial API and implementation
* James Blackburn (Broadcom Corp.)
* Baltasar Belyavsky (Texas Instruments) - bug 340219: Project metadata files are saved unnecessarily
*******************************************************************************/
package org.eclipse.cdt.internal.core.settings.model;
@ -65,14 +66,14 @@ public class SetCProjectDescriptionOperation extends CModelOperation {
AbstractCProjectDescriptionStorage.fireAboutToApplyEvent(fSetDescription, fOldDescriptionCache);
CProjectDescription fNewDescriptionCache = null;
SettingsContext context = new SettingsContext(project);
boolean modified = false;
boolean needsSerialization = false;
if(fSetDescription != null){
ICStorageElement newEl = null;
ICSettingsStorage newStorage = null;
try {
ICStorageElement base = fSetDescription.getRootStorageElement();
modified = fSetDescription.isModified();
needsSerialization = fSetDescription.needsDescriptionPersistence();
// el = base;
// FIXME JBB there is deep magic going on here. The project descriptions are being
// changed in non-obvious ways
@ -94,13 +95,11 @@ public class SetCProjectDescriptionOperation extends CModelOperation {
boolean envStates[] = getEnvStates(fNewDescriptionCache);
try {
fPrjDescStorage.setThreadLocalProjectDesc(fNewDescriptionCache);
modified |= fNewDescriptionCache.applyDatas(context);
fNewDescriptionCache.applyDatas(context);
} finally {
fPrjDescStorage.setThreadLocalProjectDesc(null);
setEnvStates(fNewDescriptionCache, envStates);
}
} else {
modified = fOldDescriptionCache != null;
}
ICDescriptionDelta delta = mngr.createDelta(fNewDescriptionCache, fOldDescriptionCache);
@ -143,7 +142,7 @@ public class SetCProjectDescriptionOperation extends CModelOperation {
try {
IWorkspaceRunnable toRun = null;
if(fNewDescriptionCache != null && !CProjectDescriptionManager.checkFlags(fFlags, ICProjectDescriptionManager.SET_NO_SERIALIZE)){
if(modified || isPersistentCoreSettingChanged(event)){
if(needsSerialization || isPersistentCoreSettingChanged(event)){
toRun = fPrjDescStorage.createDesSerializationRunnable();
if (toRun != null)
context.addWorkspaceRunnable(toRun);
@ -182,7 +181,8 @@ public class SetCProjectDescriptionOperation extends CModelOperation {
return true;
int flags = delta.getChangeFlags();
if(flags != 0 && flags != ICDescriptionDelta.ACTIVE_CFG)
// check for any flag except ACTIVE_CFG and SETTING_CFG
if((flags & ~(ICDescriptionDelta.ACTIVE_CFG | ICDescriptionDelta.SETTING_CFG)) != 0)
return true;
return false;