classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] FYI: GridBagLayout.ArrangeGrid fix


From: Thomas Fitzsimmons
Subject: [cp-patches] FYI: GridBagLayout.ArrangeGrid fix
Date: Tue, 06 Dec 2005 16:23:47 -0500

Hi,

An application I was running exposed a crash in
GridBagLayout.ArrangeGrid.  I committed this fix.

Tom

2005-12-06  Thomas Fitzsimmons  <address@hidden>

        * java/awt/GridBagLayout.java (ArrangeGrid): Use info rather than
        layoutInfo in the component for loop.  Cache layout information
        after resizing components.

Index: java/awt/GridBagLayout.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/awt/GridBagLayout.java,v
retrieving revision 1.22
diff -u -r1.22 GridBagLayout.java
--- java/awt/GridBagLayout.java 18 Oct 2005 20:06:15 -0000      1.22
+++ java/awt/GridBagLayout.java 6 Dec 2005 21:16:18 -0000
@@ -341,11 +341,14 @@
       GridBagLayoutInfo info = getLayoutInfo (parent, PREFERREDSIZE);
       if (info.cols == 0 && info.rows == 0)
         return;
-      layoutInfo = info;
 
       // DEBUG
-      //dumpLayoutInfo (layoutInfo);
-    
+      //dumpLayoutInfo (info);
+
+      // Calling setBounds on these components causes this layout to
+      // be invalidated, clearing the layout information cache,
+      // layoutInfo.  So we wait until after this for loop to set
+      // layoutInfo.
       for(int i = 0; i < components.length; i++)
        {
           Component component = components [i];
@@ -357,11 +360,11 @@
           GridBagConstraints constraints =
               lookupInternalConstraints(component);
 
-          int cellx = sumIntArray(layoutInfo.colWidths, constraints.gridx);
-          int celly = sumIntArray(layoutInfo.rowHeights, constraints.gridy);
-          int cellw = sumIntArray(layoutInfo.colWidths,
+          int cellx = sumIntArray(info.colWidths, constraints.gridx);
+          int celly = sumIntArray(info.rowHeights, constraints.gridy);
+          int cellw = sumIntArray(info.colWidths,
                                   constraints.gridx + constraints.gridwidth) - 
cellx;
-          int cellh = sumIntArray(layoutInfo.rowHeights,
+          int cellh = sumIntArray(info.rowHeights,
                                   constraints.gridy + constraints.gridheight) 
- celly;
 
           Insets insets = constraints.insets;
@@ -438,11 +441,14 @@
               break;
            }
 
-          component.setBounds(layoutInfo.pos_x + x, layoutInfo.pos_y + y, 
dim.width, dim.height);
+          component.setBounds(info.pos_x + x, info.pos_y + y, dim.width, 
dim.height);
        }
 
       // DEBUG
-      //dumpLayoutInfo (layoutInfo);
+      //dumpLayoutInfo (info);
+
+      // Cache layout information.
+      layoutInfo = getLayoutInfo (parent, PREFERREDSIZE);
     }
 
     /**

reply via email to

[Prev in Thread] Current Thread [Next in Thread]