You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Chunrong Lai (JIRA)" <ji...@apache.org> on 2007/10/30 05:24:50 UTC
[jira] Updated: (HARMONY-4820) [classlib][swing] potential dead
loop in function of SwingUtilities.getDeepestComponentAt()
[ https://issues.apache.org/jira/browse/HARMONY-4820?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Chunrong Lai updated HARMONY-4820:
----------------------------------
Attachment: H4820.fix.patch
Here is the patch.
> [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.