Xcos preferences: fix NPE on keystroke change 21/9321/3
Clément DAVID [Fri, 28 Sep 2012 12:38:14 +0000 (14:38 +0200)]
A keystroke update will emit a PropertyChangeEvent on StartAction

Change-Id: Iebfe98fc1874a3faa341e0369471823cbfcad9c8

scilab/modules/xcos/src/java/org/scilab/modules/xcos/actions/SimulationNotRunningAction.java

index 6b40b4c..5cb77e2 100644 (file)
@@ -27,7 +27,7 @@ import org.scilab.modules.graph.actions.base.GraphActionManager;
 public abstract class SimulationNotRunningAction extends DefaultAction {
     /**
      * Default constructor
-     * 
+     *
      * @param scilabGraph
      *            the associated scilab graph
      */
@@ -35,12 +35,14 @@ public abstract class SimulationNotRunningAction extends DefaultAction {
         super(scilabGraph);
 
         GraphActionManager.get(scilabGraph, StartAction.class)
-                .addPropertyChangeListener(new PropertyChangeListener() {
-                    @Override
-                    public void propertyChange(PropertyChangeEvent evt) {
-                        setEnabled((Boolean) evt.getNewValue());
-                    }
-                });
+        .addPropertyChangeListener(new PropertyChangeListener() {
+            @Override
+            public void propertyChange(PropertyChangeEvent evt) {
+                if (evt != null && evt.getNewValue() instanceof Boolean) {
+                    setEnabled((Boolean) evt.getNewValue());
+                }
+            }
+        });
     }
 
 }