harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r558824 - in /harmony/enhanced/classlib/trunk/modules/awt/src: main/java/common/java/awt/Toolkit.java test/api/java/common/java/awt/ToolkitTest.java
Date Mon, 23 Jul 2007 18:25:26 GMT
Author: ayza
Date: Mon Jul 23 11:25:25 2007
New Revision: 558824

URL: http://svn.apache.org/viewvc?view=rev&rev=558824
Log:
Applying patch from HARMONY-4491 ([classlib][awt] Exception when trying to create custom cursor)

Modified:
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Toolkit.java
    harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/ToolkitTest.java

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Toolkit.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Toolkit.java?view=diff&rev=558824&r1=558823&r2=558824
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Toolkit.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Toolkit.java
Mon Jul 23 11:25:25 2007
@@ -733,9 +733,15 @@
             throws IndexOutOfBoundsException, HeadlessException {
         lockAWT();
         try {
-            int w = img.getWidth(null), x = hotSpot.x;
-            int h = img.getHeight(null), y = hotSpot.y;
-            if (x < 0 || x >= w || y < 0 || y >= h) {
+            int w = img.getWidth(null);
+            int h = img.getHeight(null);
+
+            if (w < 0 || h < 0) {
+                // Fix for HARMONY-4491
+                hotSpot.x = 0;
+                hotSpot.y = 0;
+            } else if (hotSpot.x < 0 || hotSpot.x >= w
+                    || hotSpot.y < 0 || hotSpot.y >= h) {
                 // awt.7E=invalid hotSpot
                 throw new IndexOutOfBoundsException(Messages.getString("awt.7E")); //$NON-NLS-1$
             }

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/ToolkitTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/ToolkitTest.java?view=diff&rev=558824&r1=558823&r2=558824
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/ToolkitTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/ToolkitTest.java
Mon Jul 23 11:25:25 2007
@@ -40,4 +40,14 @@
         }
     }
 
+    public void testCreateCustomCursor() {
+        try {
+            // Regression for HARMONY-4491
+            Toolkit tk = Toolkit.getDefaultToolkit();            
+            Image img = tk.createImage(new byte[] { 0 } );
+            Cursor cursor = tk.createCustomCursor(img, new Point(0, 0), "");
+        } catch (IndexOutOfBoundsException e) {
+            fail("Unexpected IndexOutOfBoundsException");            
+        }
+    }
 }



Mime
View raw message