changeset 1459:2ca0c5dc56ee

Approved fix for RT-23062: Scene not getting garbage collected
author Lubomir Nerad <lubomir.nerad@oracle.com>
date Fri, 13 Jul 2012 10:25:02 +0200
parents 802e47751653
children 871aea815e7a
files javafx-ui-common/src/com/sun/javafx/css/parser/CSSParser.java javafx-ui-common/src/javafx/scene/Scene.java
diffstat 2 files changed, 13 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-common/src/com/sun/javafx/css/parser/CSSParser.java	Thu Jul 12 14:18:08 2012 -0700
+++ b/javafx-ui-common/src/com/sun/javafx/css/parser/CSSParser.java	Fri Jul 13 10:25:02 2012 +0200
@@ -273,6 +273,10 @@
             }
             stylesheet.getRules().addAll(rules);
         }
+
+        // don't retain reference to the styleable
+        setInputSource((Styleable) null);
+
         return stylesheet;
     }
 
--- a/javafx-ui-common/src/javafx/scene/Scene.java	Thu Jul 12 14:18:08 2012 -0700
+++ b/javafx-ui-common/src/javafx/scene/Scene.java	Fri Jul 13 10:25:02 2012 +0200
@@ -577,16 +577,19 @@
     private ReadOnlyObjectWrapper<Window> windowPropertyImpl() {
         if (window == null) {
             window = new ReadOnlyObjectWrapper<Window>() {
+                private Window oldWindow;
+
                 @Override protected void invalidated() {
-                    if (get() != null) {
+                    final Window newWindow = get();
+                    getKeyHandler().windowForSceneChanged(oldWindow, newWindow);
+                    if (oldWindow != null) {
                         impl_disposePeer();
                     }
-                    Window oldWindow = get();
-                    KeyHandler kh = getKeyHandler();
-                    kh.windowForSceneChanged(oldWindow, get());
-                    if (get() != null) {
+                    if (newWindow != null) {
                         impl_initPeer();
                     }
+
+                    oldWindow = newWindow;
                 }
 
                 @Override
@@ -3437,7 +3440,7 @@
             focusOwner.set(value);
         }
 
-        private boolean windowFocused = true;
+        private boolean windowFocused;
         protected boolean isWindowFocused() { return windowFocused; }
         protected void setWindowFocused(boolean value) {
             windowFocused = value;
@@ -3465,10 +3468,6 @@
             }
         };
 
-        public KeyHandler() {
-            windowForSceneChanged(Scene.this.getWindow(), Scene.this.getWindow()); // to init windowFocused properly
-        }
-
         private void process(KeyEvent e) {
             final Node sceneFocusOwner = getFocusOwner();
             final EventTarget eventTarget =