From 88bf01e541760bb2aeeb82656f80d5ed9ffbf67b Mon Sep 17 00:00:00 2001 From: Baltasar Belyavsky Date: Sat, 11 Feb 2012 08:29:43 -0500 Subject: bug 340219: Project metadata files are saved unnecessarily, patch to address .cproject file modifications --- .../core/settings/model/CProjectDescription.java | 34 +++++++++++----------- .../model/SetCProjectDescriptionOperation.java | 16 +++++----- 2 files changed, 25 insertions(+), 25 deletions(-) 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 f4a39275739..e140e2f0bc0 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 @@ -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 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); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/SetCProjectDescriptionOperation.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/SetCProjectDescriptionOperation.java index d8414d40197..2734232f2c9 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/SetCProjectDescriptionOperation.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/SetCProjectDescriptionOperation.java @@ -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; -- cgit v1.2.3