diff options
Diffstat (limited to 'bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/PreferenceModifyListener.java')
-rw-r--r-- | bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/PreferenceModifyListener.java | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/PreferenceModifyListener.java b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/PreferenceModifyListener.java index 0f5198221..57f9d3b4a 100644 --- a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/PreferenceModifyListener.java +++ b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/PreferenceModifyListener.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 IBM Corporation and others. + * Copyright (c) 2007, 2013 IBM 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 @@ -14,6 +14,7 @@ import org.eclipse.core.runtime.preferences.ConfigurationScope; import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.core.runtime.preferences.InstanceScope; import org.osgi.service.prefs.BackingStoreException; +import org.osgi.service.prefs.Preferences; public class PreferenceModifyListener extends org.eclipse.core.runtime.preferences.PreferenceModifyListener { @@ -23,11 +24,20 @@ public class PreferenceModifyListener extends } public IEclipsePreferences preApply(IEclipsePreferences node) { + // the node does not need to be the root of the hierarchy + Preferences root = node.node("/"); //$NON-NLS-1$ try { - if (node.nodeExists(InstanceScope.SCOPE)) { - ((ProxyManager)ProxyManager.getProxyManager()).migrateInstanceScopePreferences( - node.node(InstanceScope.SCOPE).node(Activator.ID), - node.node(ConfigurationScope.SCOPE).node(Activator.ID), false); + // we must not create empty preference nodes, so first check if the node exists + if (root.nodeExists(InstanceScope.SCOPE)) { + Preferences instance = root.node(InstanceScope.SCOPE); + // we must not create empty preference nodes, so first check if the node exists + if (instance.nodeExists(Activator.ID)) { + ((ProxyManager) ProxyManager.getProxyManager()) + .migrateInstanceScopePreferences( + instance.node(Activator.ID), + root.node(ConfigurationScope.SCOPE).node( + Activator.ID), false); + } } } catch (BackingStoreException e) { Activator.logError("Could not access instance preferences", e); //$NON-NLS-1$ |