changeset 1298:d014ba0c953c

fix RT-22466 Adding, removing then adding the same MenuBar instance in the scenegraph triggers NPE.
author Paru Somashekar <paru.somashekar@oracle.com>
date Wed, 13 Jun 2012 11:27:18 -0700
parents e6d1c213886d
children 2bad47ac2ab8
files javafx-ui-controls/src/com/sun/javafx/scene/control/skin/MenuBarSkin.java
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/MenuBarSkin.java	Wed Jun 13 16:18:07 2012 +1200
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/MenuBarSkin.java	Wed Jun 13 11:27:18 2012 -0700
@@ -310,11 +310,13 @@
             public void changed(ObservableValue<? extends Scene> ov, Scene t, Scene t1) {
                 if (weakSceneKeyEventHandler != null) {
                     // remove event filter from the old scene (t)
-                    t.removeEventFilter(KeyEvent.KEY_PRESSED, weakSceneKeyEventHandler);
+                    if (t != null)
+                        t.removeEventFilter(KeyEvent.KEY_PRESSED, weakSceneKeyEventHandler);
                 }
                 if (weakSceneMouseEventHandler != null) {
                     // remove event filter from the old scene (t)
-                    t.removeEventFilter(MouseEvent.MOUSE_CLICKED, weakSceneMouseEventHandler);
+                    if (t != null)
+                        t.removeEventFilter(MouseEvent.MOUSE_CLICKED, weakSceneMouseEventHandler);
                 }
             }
         });