classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] FYI: Revert imageio registration change


From: Mark Wielaard
Subject: [cp-patches] FYI: Revert imageio registration change
Date: Fri, 02 Sep 2005 11:11:00 +0200

Hi,

The imageio regressions in Mauve came from the big ClasspathToolkit
cleanup. We really need to register the "built-in" ImageIOSpis of the
Toolkit each time we create an IIORegistry since they are cached per
ThreadGroup. It cannot be done just at Toolkit initialization time.
Luckily this is only a very small part of the cleanup and can be done
with an empty implementation so it doesn't impact any other (non-gtk)
Toolkit.

2005-09-02  Mark Wielaard  <address@hidden>

    * gnu/java/awt/ClasspathToolkit.java (registerImageIOSpis):
    Reintroduced (empty) method.
    * gnu/java/awt/peer/gtk/GtkToolkit.java (static): Moved initialization
    of imageIOSpis to new registerImageIOSpis() method.
    (registerImageIOSpis): New (overloaded) method.
    * javax/imageio/spi/IIORegistry.java (IIORegistry): Call to Toolkit
    registration method if instanceof ClasspathToolkit.

This makes all mauve imageio tests pass again.

Thomas suggested on irc to turn the GdkPixbufDecoder into a real spi
that gets registered through a new META-INFO services file. But that
would mean some non-trivial build/configury changes to rip it out of the
rest of the GtkToolkit that I didn't want to do just before the 0.18
release. But this is now a new bug:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23690

Committed,

Mark
Index: gnu/java/awt/ClasspathToolkit.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/ClasspathToolkit.java,v
retrieving revision 1.18
diff -u -r1.18 ClasspathToolkit.java
--- gnu/java/awt/ClasspathToolkit.java  1 Sep 2005 23:03:00 -0000       1.18
+++ gnu/java/awt/ClasspathToolkit.java  2 Sep 2005 00:59:00 -0000
@@ -1,5 +1,5 @@
 /* ClasspathToolkit.java -- Abstract superclass for Classpath toolkits.
-   Copyright (C) 2003, 2004  Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004, 2005  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -203,4 +203,11 @@
    * @param w The embedded window with which to associate a peer.
    */
   public abstract EmbeddedWindowPeer createEmbeddedWindow (EmbeddedWindow w);
+
+  /**
+   * Used to register ImageIO SPIs provided by the toolkit.
+   */
+   public void registerImageIOSpis(IIORegistry reg)
+   {
+   }
 }
Index: gnu/java/awt/peer/gtk/GtkToolkit.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/GtkToolkit.java,v
retrieving revision 1.76
diff -u -r1.76 GtkToolkit.java
--- gnu/java/awt/peer/gtk/GtkToolkit.java       19 Aug 2005 01:29:26 -0000      
1.76
+++ gnu/java/awt/peer/gtk/GtkToolkit.java       2 Sep 2005 00:59:00 -0000
@@ -122,9 +122,6 @@
 
     gtkInit(portableNativeSync);
 
-    // Register ImageIO SPIs
-    GdkPixbufDecoder.registerSpis( IIORegistry.getDefaultInstance() );
-
     mainThread = new Thread ("GTK main thread")
       {
         public void run ()
@@ -654,6 +651,11 @@
   public RobotPeer createRobot (GraphicsDevice screen) throws AWTException
   {
     return new GdkRobotPeer (screen);
+  }
+
+  public void registerImageIOSpis(IIORegistry reg)
+  {
+    GdkPixbufDecoder.registerSpis(reg);
   }
 
   public static native void gtkMain();
Index: javax/imageio/spi/IIORegistry.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/imageio/spi/IIORegistry.java,v
retrieving revision 1.7
diff -u -r1.7 IIORegistry.java
--- javax/imageio/spi/IIORegistry.java  14 Aug 2005 20:36:58 -0000      1.7
+++ javax/imageio/spi/IIORegistry.java  2 Sep 2005 00:59:01 -0000
@@ -39,6 +39,7 @@
 package javax.imageio.spi;
 
 import gnu.classpath.ServiceFactory;
+import gnu.java.awt.ClasspathToolkit;
 
 import java.awt.Toolkit;
 import java.util.HashMap;
@@ -62,6 +63,7 @@
   
   public static synchronized IIORegistry getDefaultInstance()
   {
+    // XXX: This leaks memory if a ThreadGroup isn't available anymore.
     ThreadGroup group = Thread.currentThread().getThreadGroup();
     IIORegistry registry = (IIORegistry) instances.get(group);
     
@@ -81,6 +83,8 @@
     // XXX: Register built-in Spis here.
 
     Toolkit toolkit = Toolkit.getDefaultToolkit();
+    if (toolkit instanceof ClasspathToolkit)
+      ((ClasspathToolkit)toolkit).registerImageIOSpis(this);
     
     registerApplicationClasspathSpis();
   }

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]