7124339: [macosx] setIconImage is not endlessly tolerant to the broken image-arguments
authorserb
Wed, 07 Aug 2013 19:57:18 +0400
changeset 19179 b59142223aac
parent 19178 81fa1a77bf7b
child 19180 c0f6ff9544a9
7124339: [macosx] setIconImage is not endlessly tolerant to the broken image-arguments Reviewed-by: alexsch, leonidr
jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Wed Aug 07 18:58:28 2013 +0400
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Wed Aug 07 19:57:18 2013 +0400
@@ -830,18 +830,19 @@
     //                          UTILITY METHODS
     // ----------------------------------------------------------------------
 
-    /*
-     * Find image to install into Title or into Application icon.
-     * First try icons installed for toplevel. If there is no icon
-     * use default Duke image.
-     * This method shouldn't return null.
+    /**
+     * Find image to install into Title or into Application icon. First try
+     * icons installed for toplevel. Null is returned, if there is no icon and
+     * default Duke image should be used.
      */
     private CImage getImageForTarget() {
-        List<Image> icons = target.getIconImages();
-        if (icons == null || icons.size() == 0) {
-            return null;
+        CImage icon = null;
+        try {
+            icon = CImage.getCreator().createFromImages(target.getIconImages());
+        } catch (Exception ignored) {
+            // Perhaps the icon passed into Java is broken. Skipping this icon.
         }
-        return CImage.getCreator().createFromImages(icons);
+        return icon;
     }
 
     /*