Bug 74341 [prefs] Compatibility layer needs to handle previous changes
diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/preferences/PreferenceForwarder.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/preferences/PreferenceForwarder.java
index 4fe894c..c0ea502 100644
--- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/preferences/PreferenceForwarder.java
+++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/preferences/PreferenceForwarder.java
@@ -99,7 +99,6 @@
 	 * @see org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener#preferenceChange(org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent)
 	 */
 	public void preferenceChange(IEclipsePreferences.PreferenceChangeEvent event) {
-		dirty = true;
 		if (listeners == null)
 			return;
 		Object oldValue = event.getOldValue();
@@ -714,7 +713,7 @@
 	 *  default value, and <code>false</code> otherwise
 	 */
 	public boolean needsSaving() {
-		return dirty;
+		return getPluginPreferences().dirty;
 	}
 
 	/**
@@ -723,9 +722,7 @@
 	 * @throws BackingStoreException
 	 */
 	public void flush() throws BackingStoreException {
-		if (dirty)
-			getPluginPreferences().flush();
-		dirty = false;
+		getPluginPreferences().flush();
 	}
 
 	/**
@@ -737,7 +734,6 @@
 		// don't check the dirty flag first because there could be changes
 		// on disk that we want
 		getPluginPreferences().sync();
-		dirty = false;
 	}
 
 	/*
@@ -755,7 +751,11 @@
 		Properties result = new Properties();
 		result.load(in);
 		convertFromProperties(result);
-		dirty = false;
+		try {
+			flush();
+		} catch (BackingStoreException e) {
+			throw new IOException(e.getMessage());
+		}
 	}
 
 	/*
@@ -764,7 +764,6 @@
 	public void store(OutputStream out, String header) throws IOException {
 		Properties result = convertToProperties();
 		result.store(out, header);
-		dirty = false;
 	}
 
 	private void convertFromProperties(Properties props) {
diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Plugin.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Plugin.java
index 0e8189c..b07897a 100644
--- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Plugin.java
+++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Plugin.java
@@ -343,10 +343,10 @@
 	 * @since 2.0
 	 */
 	public final void savePluginPreferences() {
-		if (preferences == null || !preferences.needsSaving()) {
-			// nothing to save
-			return;
-		}
+		// populate the "preferences" instvar. We still might
+		// need to save them because someone else might have
+		// made changes via the OSGi APIs.
+		getPluginPreferences();
 		try {
 			preferences.flush();
 		} catch (BackingStoreException e) {