This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gui] [PATCH] Fix to Container's remove() method


Hello,

I committed the following patch to the java-gui-branch.  It fixes
Container's remove() method, such that the component's parent is not set
to null until after we removed the component from the layout manager. 
This fixes a bug where NullPointerExceptions were being thrown from
CardLayout's removeLayoutContainer(), when the component's parent was
being accessed.

-David Jee

2004-05-25  David Jee  <djee@redhat.com>

        * java/awt/Container.java
        (remove): Set component's parent to null only after we removed the
        component from its parent's layout manager.


Index: java/awt/Container.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/Container.java,v
retrieving revision 1.34.2.8
diff -u -r1.34.2.8 Container.java
--- java/awt/Container.java	22 Apr 2004 17:47:38 -0000	1.34.2.8
+++ java/awt/Container.java	25 May 2004 16:19:38 -0000
@@ -407,7 +407,6 @@
       {
         Component r = component[index];
 
-        r.parent = null;
         r.removeNotify();
 
         System.arraycopy(component, index + 1, component, index,
@@ -419,6 +418,8 @@
         if (layoutMgr != null)
           layoutMgr.removeLayoutComponent(r);
 
+        r.parent = null;
+
         // Post event to notify of adding the container.
         ContainerEvent ce = new ContainerEvent(this,
                                                ContainerEvent.COMPONENT_REMOVED,

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]