harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r590733 - in /harmony/enhanced/classlib/trunk/modules/swing/src: main/java/common/javax/swing/SwingUtilities.java test/api/java.injected/javax/swing/SwingUtilitiesRTest.java
Date Wed, 31 Oct 2007 16:25:48 GMT
Author: ayza
Date: Wed Oct 31 09:25:48 2007
New Revision: 590733

URL: http://svn.apache.org/viewvc?rev=590733&view=rev
Log:
Applying patch from HARMONY-4820 ( [classlib][swing] potential dead loop in function of SwingUtilities.getDeepestComponentAt()).
I've also added a test for this issue to SwingUtilitiesRTest.


Modified:
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/SwingUtilities.java
    harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/SwingUtilitiesRTest.java

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/SwingUtilities.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/SwingUtilities.java?rev=590733&r1=590732&r2=590733&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/SwingUtilities.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/SwingUtilities.java
Wed Oct 31 09:25:48 2007
@@ -401,6 +401,9 @@
         while (child != null && child instanceof Container) {
             parent = child;
             child = parent.getComponentAt(x, y);
+            if (child == parent) {
+                break;
+            }
         }
 
         return (child != null) ? child : parent;

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/SwingUtilitiesRTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/SwingUtilitiesRTest.java?rev=590733&r1=590732&r2=590733&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/SwingUtilitiesRTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/SwingUtilitiesRTest.java
Wed Oct 31 09:25:48 2007
@@ -22,6 +22,7 @@
  */
 package javax.swing;
 
+import java.awt.Component;
 import java.awt.Dimension;
 import java.awt.FontMetrics;
 import java.awt.Frame;
@@ -105,4 +106,44 @@
         final JDialog dialog = new JDialog(f);
         assertSame(f, SwingUtilities.getAncestorOfClass(Frame.class, dialog));
     }
+    
+    public void testDeadLoop_4820() {
+        final int DEAD_LOOP_TIMEOUT = 1000;
+        final int VALID_NUMBER_OF_CALLS = 15;
+        final int counter[] = {0};
+        
+        class MFrame extends Frame {
+            MFrame() {
+                setSize(300,200) ;
+                show();
+            }
+        
+            public Component locate(int x, int y) {
+                counter[0]++;
+                return super.locate(x,y);
+            }
+            
+            public Component getComponentAt(int x, int y) {
+                counter[0]++;
+                return super.getComponentAt(x, y);
+            }
+            
+            public Component getComponentAt(java.awt.Point p) {
+                counter[0]++;
+                return super.getComponentAt(p);
+            }
+        }
+
+        Frame f = new MFrame();
+        
+        SwingUtilities.getDeepestComponentAt(f, 10, 10);
+        try {
+            Thread.sleep(DEAD_LOOP_TIMEOUT);
+        } catch (Exception e) {}
+        
+        f.dispose();
+        
+        assertTrue("Dead loop occured", counter[0] <= VALID_NUMBER_OF_CALLS);
+    }
+
 }



Mime
View raw message