harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexei Zakharov (JIRA)" <j...@apache.org>
Subject [jira] Resolved: (HARMONY-4820) [classlib][swing] potential dead loop in function of SwingUtilities.getDeepestComponentAt()
Date Wed, 31 Oct 2007 16:27:50 GMT

     [ https://issues.apache.org/jira/browse/HARMONY-4820?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Alexei Zakharov resolved HARMONY-4820.
--------------------------------------

    Resolution: Fixed

Thanks Chunrong. You patch was committed at the revision 590733. I've also added a unit test
at the same revision. Please verify. 

> [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
>            Assignee: Alexei Zakharov
>         Attachments: H4820.fix.patch
>
>
>  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