1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fix for [Bug 203614] ICDescriptor.saveProjectData() doesn't always serialize to . cproject

This commit is contained in:
Mikhail Sennikovsky 2007-09-17 17:33:28 +00:00
parent a76abebd0c
commit 46d9a5d1b8
7 changed files with 52 additions and 21 deletions

View file

@ -279,11 +279,11 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
void doneInitialization(){ void doneInitialization(){
if(isReadOnly()){ if(isReadOnly()){
if(fRootStorageElement != null) if(fRootStorageElement != null)
((InternalXmlStorageElement)fRootStorageElement).setReadOnly(true); ((InternalXmlStorageElement)fRootStorageElement).setReadOnly(true, false);
if(fSettingsStorageElement != null) if(fSettingsStorageElement != null)
((InternalXmlStorageElement)fSettingsStorageElement).setReadOnly(true); ((InternalXmlStorageElement)fSettingsStorageElement).setReadOnly(true, false);
if(fStorage != null) if(fStorage != null)
fStorage.setReadOnly(true); fStorage.setReadOnly(true, false);
} }
} }
@ -492,7 +492,16 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
if(isReadOnly()) if(isReadOnly())
throw ExceptionFactory.createIsReadOnlyException(); throw ExceptionFactory.createIsReadOnlyException();
fIsModified = modified; fIsModified = modified;
if(!modified){
if(fMacros != null)
fMacros.setDirty(false);
if(fEnvironment != null)
fEnvironment.setDirty(false);
}
} }
void setModified(){ void setModified(){
setModified(true); setModified(true);
} }

View file

@ -232,11 +232,16 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
return modified; return modified;
} }
void doneApplying(){ void doneApplying(){
doneInitializing(); doneInitializing();
fIsApplying = false; fIsApplying = false;
try {
((InternalXmlStorageElement)getRootStorageElement()).setReadOnly(true, false);
} catch (CoreException e1) {
}
setModified(false);
} }
void doneLoadding(){ void doneLoadding(){
@ -503,6 +508,20 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
return false; return false;
} }
private void setModified(boolean modified){
fIsModified = modified;
if(!modified){
fActiveCfgInfo.fIsModified = false;
fSettingCfgInfo.fIsModified = false;
fPrefs.setModified(false);
//no need to do that for config cache since they always maintain the "isModified == false"
}
}
public boolean isReadOnly() { public boolean isReadOnly() {
return fIsReadOnly && !(fIsLoadding || fIsApplying); return fIsReadOnly && !(fIsLoadding || fIsApplying);
} }

View file

@ -709,11 +709,6 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
} finally { } finally {
clearDescriptionApplying(project); clearDescriptionApplying(project);
} }
try {
((InternalXmlStorageElement)des.getRootStorageElement()).setReadOnly(true);
} catch (CoreException e1) {
}
} }
}finally{ }finally{
CProjectDescription d = clearDescriptionLoadding(project); CProjectDescription d = clearDescriptionLoadding(project);

View file

@ -95,6 +95,10 @@ public class CProjectDescriptionPreferences implements ICProjectDescriptionPrefe
&& !fSuperPreference.settingsEqual((CProjectDescriptionPreferences)CProjectDescriptionManager.getInstance().getProjectDescriptionWorkspacePreferences(false))); && !fSuperPreference.settingsEqual((CProjectDescriptionPreferences)CProjectDescriptionManager.getInstance().getProjectDescriptionWorkspacePreferences(false)));
} }
void setModified(boolean modified){
fIsModified = modified;
}
public boolean isReadOnly(){ public boolean isReadOnly(){
return fIsReadOnly; return fIsReadOnly;
} }

View file

@ -170,11 +170,12 @@ public class CStorage implements ICSettingsStorage{
return false; return false;
} }
void setReadOnly(boolean readOnly){ void setReadOnly(boolean readOnly, boolean keepModify){
fIsReadOnly = readOnly; fIsReadOnly = readOnly;
fIsDirty &= keepModify;
for(Iterator iter = fStorageElementMap.values().iterator(); iter.hasNext();){ for(Iterator iter = fStorageElementMap.values().iterator(); iter.hasNext();){
InternalXmlStorageElement el = (InternalXmlStorageElement)iter.next(); InternalXmlStorageElement el = (InternalXmlStorageElement)iter.next();
el.setReadOnly(readOnly); el.setReadOnly(readOnly, keepModify);
} }
} }

View file

@ -61,11 +61,16 @@ public class InternalXmlStorageElement extends XmlStorageElement {
} }
public void setReadOnly(boolean readOnly){ public void setReadOnly(boolean readOnly){
setReadOnly(readOnly, true);
}
public void setReadOnly(boolean readOnly, boolean keepModify){
fIsReadOnly = readOnly; fIsReadOnly = readOnly;
fIsDirty &= keepModify;
ICStorageElement children[] = getChildren(false); ICStorageElement children[] = getChildren(false);
for(int i = 0; i < children.length; i++){ for(int i = 0; i < children.length; i++){
((InternalXmlStorageElement)children[i]).setReadOnly(readOnly); ((InternalXmlStorageElement)children[i]).setReadOnly(readOnly, keepModify);
} }
} }

View file

@ -45,11 +45,14 @@ public class SetCProjectDescriptionOperation extends CModelOperation {
mngr.notifyListeners(event); mngr.notifyListeners(event);
CProjectDescription fNewDescriptionCache = null; CProjectDescription fNewDescriptionCache = null;
SettingsContext context = new SettingsContext(project); SettingsContext context = new SettingsContext(project);
boolean modified; boolean modified = false;
if(fSetDescription != null){ if(fSetDescription != null){
InternalXmlStorageElement el = null; InternalXmlStorageElement el = null;
try { try {
el = mngr.copyElement((InternalXmlStorageElement)fSetDescription.getRootStorageElement(), false); InternalXmlStorageElement base = (InternalXmlStorageElement)fSetDescription.getRootStorageElement();
modified = base.isDirty();
el = mngr.copyElement(base, false);
} catch (CoreException e2) { } catch (CoreException e2) {
} }
@ -63,7 +66,7 @@ public class SetCProjectDescriptionOperation extends CModelOperation {
fNewDescriptionCache = new CProjectDescription(fSetDescription, true, el, creating); fNewDescriptionCache = new CProjectDescription(fSetDescription, true, el, creating);
try { try {
mngr.setDescriptionApplying(project, fNewDescriptionCache); mngr.setDescriptionApplying(project, fNewDescriptionCache);
modified = fNewDescriptionCache.applyDatas(context); modified |= fNewDescriptionCache.applyDatas(context);
} finally { } finally {
mngr.clearDescriptionApplying(project); mngr.clearDescriptionApplying(project);
} }
@ -105,11 +108,6 @@ public class SetCProjectDescriptionOperation extends CModelOperation {
// ExternalSettingsManager.getInstance().updateDepentents(delta); // ExternalSettingsManager.getInstance().updateDepentents(delta);
if(fNewDescriptionCache != null){ if(fNewDescriptionCache != null){
try {
((InternalXmlStorageElement)fNewDescriptionCache.getRootStorageElement()).setReadOnly(true);
} catch (CoreException e1) {
}
fNewDescriptionCache.doneApplying(); fNewDescriptionCache.doneApplying();
} }