eirikbakke commented on a change in pull request #1278: [NETBEANS-2604] Support 
SVG icon loading from ImageUtilities
URL: https://github.com/apache/netbeans/pull/1278#discussion_r289617980
 
 

 ##########
 File path: platform/openide.util.ui/src/org/openide/util/ImageUtilities.java
 ##########
 @@ -353,62 +429,122 @@ public static Icon createDisabledIcon(Icon icon)  {
      */
     public static Image createDisabledImage(Image image)  {
         Parameters.notNull("image", image);
-        return LazyDisabledIcon.createDisabledImage(image);
+        // Go through FilteredIcon to preserve scalable icons.
+        return icon2Image(createDisabledIcon(image2Icon(image)));
+    }
+
+    /**
+     * Get an SVG icon loader, if the appropriate service provider module is 
installed. To ensure
+     * lazy loading of the SVG loader module, this method should only be 
called when there actually
+     * exists an SVG file to load. The result is cached.
+     *
+     * @return may be null
+     */
+    private static SVGLoader getSVGLoader() {
+        /* "Objects contained in the default lookup are instantiated lazily 
when first requested."
+        ( http://wiki.netbeans.org/DevFaqLookupDefault ) So the SVGLoader 
implementation module will
+        only be loaded the first time an SVG file is actually encountered for 
loading, rather than,
+        for instance, when the startup splash screen initializes 
ImageUtilities to load its PNG
+        image. This was confirmed by printing a debugging message from a 
static initializer in
+        SVGLoaderImpl in the implementation module; the message appears well 
after the splash
+        screen's PNG graphics first becomes visible. */
+        return svgLoaderLoader.getLoader();
     }
 
     /**
      * Get the class loader from lookup.
      * Since this is done very frequently, it is wasteful to query lookup each 
time.
      * Instead, remember the last result and just listen for changes.
      */
-    static ClassLoader getLoader() {
-        Object is = currentLoader;
-        if (is instanceof ClassLoader) {
-            return (ClassLoader)is;
-        }
-            
-        currentLoader = Thread.currentThread();
-            
-        if (loaderQuery == null) {
-            loaderQuery = Lookup.getDefault().lookup(new 
Lookup.Template<ClassLoader>(ClassLoader.class));
-            loaderQuery.addLookupListener(
-                new LookupListener() {
-                    public void resultChanged(LookupEvent ev) {
-                        ERR.fine("Loader cleared"); // NOI18N
-                        currentLoader = null;
-                    }
-                }
-            );
+    static ClassLoader getClassLoader() {
+        return classLoaderLoader.getLoader();
+    }
+
+    private static final class CachedLookupLoader<T> {
 
 Review comment:
   It's mostly trying to ensure that a 14-year old race condition bugfix 
remains fixed. I would have kept this code unchanged, except I need exactly the 
same logic to retrieve the SVGLoader.
   
   I'll take a hard look at it again later, once my eyes are "fresh" again...

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to