changeset 3769:f2583a30a508

Fixed infinte loop in HBox.
author Martin Sladecek <martin.sladecek@oracle.com>
date Thu, 30 May 2013 15:42:31 +0200
parents c200cd542665
children 804a55322e91
files javafx-ui-common/src/javafx/scene/layout/HBox.java
diffstat 1 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-common/src/javafx/scene/layout/HBox.java	Thu May 30 08:19:27 2013 +0200
+++ b/javafx-ui-common/src/javafx/scene/layout/HBox.java	Thu May 30 15:42:31 2013 +0200
@@ -498,18 +498,18 @@
             }
         } else {
             for (int i = 0, size = managed.size(); i < size; i++) {
-            final Node child = managed.get(i);
-            if (getHgrow(child) == priority) {
-                temp[i] = computeChildMaxAreaWidth(child, getMargin(child), height);
-                adjustingNumber++;
-            } else {
-                temp[i] = -1;
+                final Node child = managed.get(i);
+                if (getHgrow(child) == priority) {
+                    temp[i] = computeChildMaxAreaWidth(child, getMargin(child), height);
+                    adjustingNumber++;
+                } else {
+                    temp[i] = -1;
+                }
             }
         }
-        }
 
         double available = extraWidth; // will be negative in shrinking case
-        while (Math.abs(available) > 1 && adjustingNumber > 0) {
+        outer:while (Math.abs(available) > 1 && adjustingNumber > 0) {
             final double portion = snapPortion(available / adjustingNumber); // negative in shrinking case
             for (int i = 0, size = managed.size(); i < size; i++) {
                 if (temp[i] == -1) {
@@ -519,8 +519,8 @@
                 final double change = Math.abs(limit) <= Math.abs(portion)? limit : portion;
                 usedWidths[i] += change;
                 available -= change;
-                if (available == 0) {
-                    break;
+                if (Math.abs(available) < 1) {
+                    break outer;
                 }
                 if (Math.abs(change) < Math.abs(portion)) {
                     temp[i] = -1;