changeset 1815:9352015d712d

RT-24784: ensure parent style manager is properly initialized
author David Grieve<david.grieve@oracle.com>
date Fri, 12 Oct 2012 14:51:58 -0400
parents 393c90eb52e0
children c731a926c171
files javafx-ui-common/src/javafx/scene/Parent.java
diffstat 1 files changed, 20 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-common/src/javafx/scene/Parent.java	Fri Oct 12 14:51:58 2012 -0400
+++ b/javafx-ui-common/src/javafx/scene/Parent.java	Fri Oct 12 14:51:58 2012 -0400
@@ -1115,28 +1115,28 @@
         
         styleManager = null;
         
-        final boolean hasStylesheets = (getStylesheets().isEmpty() == false);
+        final Scene scene = getScene();
+        if (scene == null) return null;
+
+        // This Parent's styleManager will chain to the styleManager of 
+        // one of its ancestors, or to the scene styleManager.
+        StyleManager parentStyleManager = null;
+        Parent parent = getParent();
+        while (parent != null && parentStyleManager == null) {
+            parentStyleManager = parent.getStyleManager();
+            parent = parent.getParent();
+        }
         
-        if (hasStylesheets) {
-
-            // This Parent's styleManager will chain to the styleManager of 
-            // one of its ancestors, or to the scene styleManager.
-            StyleManager parentStyleManager = null;
-            Parent parent = getParent();
-            while (parent != null && 
-                    (parentStyleManager = parent.getStyleManager()) == null) {
-                parent = parent.getParent();
-            }
+        if (parentStyleManager == null) parentStyleManager = scene.styleManager;
+        
+        if (getStylesheets().isEmpty() == false) {
             
-            if (parentStyleManager != null) {
-                styleManager = 
-                    StyleManager.createStyleManager(Parent.this, parentStyleManager);
-            } else {
-                final Scene scene = getScene();
-                if (scene != null) {
-                    StyleManager.createStyleManager(Parent.this, scene.styleManager);
-                }
-            } 
+            styleManager = 
+                StyleManager.createStyleManager(Parent.this, parentStyleManager);
+            
+        } else {
+            
+            styleManager = parentStyleManager; 
         
         }
         return styleManager;