changeset 4937:5c3ec77e5d2a

RT-31865: check error status of image, return null from CSS image cache if image isError
author David Grieve<david.grieve@oracle.com>
date Thu, 05 Sep 2013 17:02:27 -0400
parents 39bc7a47c6cb
children 5707c927c106
files modules/controls/src/main/java/javafx/scene/control/Labeled.java modules/graphics/src/main/java/com/sun/javafx/css/StyleManager.java
diffstat 2 files changed, 24 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/modules/controls/src/main/java/javafx/scene/control/Labeled.java	Thu Sep 05 17:02:25 2013 -0400
+++ b/modules/controls/src/main/java/javafx/scene/control/Labeled.java	Thu Sep 05 17:02:27 2013 -0400
@@ -468,7 +468,9 @@
                         }
                         if (url != null) {
                             final Image img = StyleManager.getInstance().getCachedImage(url.toExternalForm());
-                            ((StyleableProperty)graphicProperty()).applyStyle(origin, new ImageView(img));
+                            if (img != null) {
+                                ((StyleableProperty)graphicProperty()).applyStyle(origin, new ImageView(img));
+                            }
                         }
                     }
                 }
--- a/modules/graphics/src/main/java/com/sun/javafx/css/StyleManager.java	Thu Sep 05 17:02:25 2013 -0400
+++ b/modules/graphics/src/main/java/com/sun/javafx/css/StyleManager.java	Thu Sep 05 17:02:27 2013 -0400
@@ -25,6 +25,8 @@
 
 package com.sun.javafx.css;
 
+import javafx.beans.value.ChangeListener;
+import javafx.beans.value.ObservableValue;
 import javafx.css.Styleable;
 import java.io.FileNotFoundException;
 import java.io.FilePermission;
@@ -672,26 +674,40 @@
 
     public Image getCachedImage(String url) {
 
-        Image image = imageCache.get(url);
-        if (image == null) {
+        Image image = null;
+        if (imageCache.containsKey(url)) {
+
+            image = imageCache.get(url);
+
+        } else {
 
             try {
 
                 image = new Image(url);
-                imageCache.put(url, image);
+
+                // RT-31865
+                if (image.isError() == false) {
+                    imageCache.put(url, image);
+                } else {
+                    imageCache.put(url, null);
+                    final PlatformLogger logger = getLogger();
+                    if (logger != null && logger.isLoggable(Level.WARNING)) {
+                        logger.warning("Error loading image: " + url);
+                    }
+                }
 
             } catch (IllegalArgumentException iae) {
                 // url was empty!
                 final PlatformLogger logger = getLogger();
                 if (logger != null && logger.isLoggable(Level.WARNING)) {
-                        LOGGER.warning(iae.getLocalizedMessage());
+                    logger.warning(iae.getLocalizedMessage());
                 }
 
             } catch (NullPointerException npe) {
                 // url was null!
                 final PlatformLogger logger = getLogger();
                 if (logger != null && logger.isLoggable(Level.WARNING)) {
-                        LOGGER.warning(npe.getLocalizedMessage());
+                    logger.warning(npe.getLocalizedMessage());
                 }
             }
         }