changeset 7726:d8500a1bace1

RT-37092: Updated fix to avoid NPE in unit tests.
author leifs
date Tue, 19 Aug 2014 16:50:11 -0700
parents dc016eecc27e
children e482cf3b4593
files modules/controls/src/main/java/com/sun/javafx/scene/control/skin/Utils.java
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/Utils.java	Wed Aug 20 09:21:10 2014 +1200
+++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/Utils.java	Tue Aug 19 16:50:11 2014 -0700
@@ -59,6 +59,7 @@
 import com.sun.javafx.scene.control.behavior.TextBinding;
 import com.sun.javafx.scene.text.HitInfo;
 import com.sun.javafx.scene.text.TextLayout;
+import com.sun.javafx.scene.text.TextLine;
 import com.sun.javafx.tk.Toolkit;
 import javafx.util.Callback;
 
@@ -109,8 +110,14 @@
         } else {
             layout.setBoundsType(0);
         }
-        // RT-37092: Use the line bounds specifically, to include font leading.
-        return layout.getLines()[0].getBounds().getHeight();
+
+        TextLine[] textLines = layout.getLines();
+        if (textLines != null && textLines.length > 0) {
+            // RT-37092: Use the line bounds specifically, to include font leading.
+            return textLines[0].getBounds().getHeight();
+        } else {
+            return layout.getBounds().getHeight();
+        }
     }
 
     static double computeTextWidth(Font font, String text, double wrappingWidth) {