summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Eidsness2013-12-16 12:46:43 (EST)
committerSergey Prigogin2013-12-17 17:17:59 (EST)
commit213687547774c626cc6fafd94524209acf363231 (patch)
tree064155c920f76dab49c866962ce97c4d7fbf9f3c
parent4cfdc239bcdcf8841f7ef0117508902cba9ddc7f (diff)
downloadorg.eclipse.cdt-213687547774c626cc6fafd94524209acf363231.zip
org.eclipse.cdt-213687547774c626cc6fafd94524209acf363231.tar.gz
org.eclipse.cdt-213687547774c626cc6fafd94524209acf363231.tar.bz2
Bug 424160: null checks for CodanPreferencesLoader.getProjectNoderefs/changes/73/19873/4
CodanPreferencesLoader.getProjectNode will sometimes return null. This patch adds null checks before using the result. Change-Id: If4dd70e6673d5da62cc0b8e899fb5066bdaa4bef Signed-off-by: Andrew Eidsness <eclipse@jfront.com> Reviewed-on: https://git.eclipse.org/r/19873 Tested-by: Hudson CI Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com> IP-Clean: Sergey Prigogin <eclipse.sprigogin@gmail.com> Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
-rw-r--r--codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CheckersRegistry.java18
-rw-r--r--codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/uicontrib/ProfileChangeListener.java4
2 files changed, 12 insertions, 10 deletions
diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CheckersRegistry.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CheckersRegistry.java
index 89ec54f..37d5f16 100644
--- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CheckersRegistry.java
+++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CheckersRegistry.java
@@ -11,13 +11,6 @@
*******************************************************************************/
package org.eclipse.cdt.codan.internal.core;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
import org.eclipse.cdt.codan.core.CodanCorePlugin;
import org.eclipse.cdt.codan.core.PreferenceConstants;
import org.eclipse.cdt.codan.core.model.AbstractCheckerWithProblemPreferences;
@@ -47,6 +40,13 @@ import org.eclipse.core.runtime.preferences.DefaultScope;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.osgi.service.prefs.Preferences;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
/**
* Implementation of checker registry interface
*/
@@ -368,8 +368,8 @@ public class CheckersRegistry implements Iterable<IChecker>, ICheckersRegistry {
// Load default values
CodanPreferencesLoader loader = new CodanPreferencesLoader(prof);
Preferences projectNode = CodanPreferencesLoader.getProjectNode((IProject) element);
- boolean useWorkspace = projectNode.getBoolean(PreferenceConstants.P_USE_PARENT, true);
- if (!useWorkspace) {
+ if (projectNode != null &&
+ !projectNode.getBoolean(PreferenceConstants.P_USE_PARENT, true)) {
loader.load(projectNode);
}
profiles.put(element, prof);
diff --git a/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/uicontrib/ProfileChangeListener.java b/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/uicontrib/ProfileChangeListener.java
index 7f4c22c..e6b5050 100644
--- a/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/uicontrib/ProfileChangeListener.java
+++ b/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/uicontrib/ProfileChangeListener.java
@@ -49,7 +49,9 @@ public class ProfileChangeListener implements INodeChangeListener, IPreferenceCh
IProject[] projects = root.getRoot().getProjects();
for (int i = 0; i < projects.length; i++) {
IProject project = projects[i];
- CodanPreferencesLoader.getProjectNode(project).addPreferenceChangeListener(new ProfileChangeListener(project));
+ IEclipsePreferences prefs = CodanPreferencesLoader.getProjectNode(project);
+ if (prefs != null)
+ prefs.addPreferenceChangeListener(new ProfileChangeListener(project));
}
// cannot do on plugin startup
// CheckersRegistry.getInstance().getWorkspaceProfile().addProfileChangeListener(this);