Hi,

On Sun, 2006-06-11 at 23:59 +0200, Mark Wielaard wrote:
> This solves a gdk lockup in GdkPixbufWriter by implementing the
> suggestion in the FIXME. Now we don't drop and re-acquire the gdk-lock
> but store the data and push that to the user code from a separate
> thread.

Here is a small refinement. We were not notifying the worker thread when
we were completely done. We now also store and rethrow any IOException.

2006-06-12  Mark Wielaard  <[EMAIL PROTECTED]>

    * gnu/java/awt/peer/gtk/GdkPixbufDecoder.java (streamImage):
    Notify data when completely done. Wait for worker thread to finish.
    Rethrow any pending exceptions.
    (exception): New field.
    (run): Store pending exception.

Committed,

Mark
Index: gnu/java/awt/peer/gtk/GdkPixbufDecoder.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/GdkPixbufDecoder.java,v
retrieving revision 1.23
diff -u -r1.23 GdkPixbufDecoder.java
--- gnu/java/awt/peer/gtk/GdkPixbufDecoder.java	11 Jun 2006 22:02:14 -0000	1.23
+++ gnu/java/awt/peer/gtk/GdkPixbufDecoder.java	12 Jun 2006 08:42:20 -0000
@@ -526,7 +526,8 @@
           model = img.getColorModel();
         }
 
-      new Thread(this, "GdkPixbufWriter").start();
+      Thread workerThread = new Thread(this, "GdkPixbufWriter");
+      workerThread.start();
       processImageStarted(1);
       synchronized(pixbufLock)
 	{
@@ -536,7 +537,25 @@
       synchronized(data)
         {
           data.add(DATADONE);
+          data.notifyAll();
+        }
+
+      while (workerThread.isAlive())
+        {
+	  try
+	    {
+	      workerThread.join();
+	    }
+	  catch (InterruptedException ioe)
+	    {
+	      // Ignored.
+	    }
         }
+
+      if (exception != null)
+	throw exception;
+
+      processImageComplete();
     }    
 
     /**
@@ -552,6 +571,12 @@
      */
     private ArrayList data = new ArrayList();
 
+    /**
+     * Holds any IOException thrown by the run method that needs
+     * to be rethrown by the write method.
+     */
+    private IOException exception;
+
     /** Callback for streamImage native code. **/
     private void write(byte[] bs)
     {
@@ -593,12 +618,13 @@
                     }
                   catch (IOException ioe)
                     {
-                      // Not much we can do now...
+                      // We are only interested in the first exception.
+                      if (exception == null)
+                        exception = ioe;
                     }
                 }
             }
         }
-      processImageComplete();
     }
   }
 

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

Reply via email to