harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chunrong Lai (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-4820) [classlib][swing] potential dead loop in function of SwingUtilities.getDeepestComponentAt()
Date Wed, 19 Sep 2007 06:47:43 GMT
[classlib][swing] potential dead loop in function of SwingUtilities.getDeepestComponentAt()
-------------------------------------------------------------------------------------------

                 Key: HARMONY-4820
                 URL: https://issues.apache.org/jira/browse/HARMONY-4820
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
         Environment: Win32 + Linux32
            Reporter: Chunrong Lai



 Below is the reproducer.

import   java.awt.*   ;   
import   javax.swing.*; 
    
public class   MFrame   extends   Frame{   
  MFrame(){   
    setSize(300,200)   ;   
    show();
  }   

  public   static   void   main(String   args[]){   
    Component aComponent = SwingUtilities.getDeepestComponentAt(new MFrame(), 10, 10);
    System.out.println("the deepest Component is " + aComponent);
  }   
}

 RI is OK for above test.
 If we look at the code of Harmony it just have an endless loop if called with the deepestComponent.

    public static Component getDeepestComponentAt(final Component component, final int x,
final int y) {
        if (!component.contains(x, y)) {
            return null;
        }

        Component parent = component;
        Component child = parent;
        while (child != null && child instanceof Container) {
            parent = child;
            child = parent.getComponentAt(x, y); 
        }

        return (child != null) ? child : parent;
    }

    public Component locate(int x, int y) {
        toolkit.lockAWT();
        try {
            if (contains(x, y)) {
                return this;   //child.locate(x,y) == child; endless loop
            }
            return null;
        } finally {
            toolkit.unlockAWT();
        }
    }


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message