This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gui] [PATCH] Fix MediaTracker.addImage()


Hello,

I committed the following patch to the java-gui-branch.  It fixes
MediaTracker.addImage(), so that it calls MediaTracker.imageUpdate() on
the newly added MediaEntry.  This ensures that the MediaEntry has the
latest image status, and it also ensures that any thread that has been
waiting for the image to load is notified if necessary.

This latter scenario seems unlikely, since it doesn't make sense to call
MediaTracker.waitForID() or MediaTracker.waitForAll() until you've
registered the image first with addImage().  However, there is a case
where waitForID() or waitForAll() is called after addImage(), but the
image has already finished loading before addImage() was even called. 
In this case, unless imageUpdate() is called, the waiting threads will
never be notified that the image is complete, resulting in an infinite
wait.

-David Jee

2004-06-11  David Jee  <djee@redhat.com>

        * java/awt/MediaTracker.java
        (addImage(Image,int)): Call imageUpdate() to udpate image status.
        (addImage(Image,int,int,int)): Likewise.


Index: java/awt/MediaTracker.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/MediaTracker.java,v
retrieving revision 1.5.10.2
diff -u -r1.5.10.2 MediaTracker.java
--- java/awt/MediaTracker.java	10 Jun 2004 16:11:51 -0000	1.5.10.2
+++ java/awt/MediaTracker.java	11 Jun 2004 16:21:52 -0000
@@ -111,7 +111,8 @@
     e.next = head;
     head = e;
     // Start tracking image status.
-    target.checkImage(image, e);
+    int flags = target.checkImage(image, e);
+    e.imageUpdate(image, flags, -1, -1, -1, -1);
   }
 
   public void addImage(Image image, int id, int width, int height)
@@ -124,7 +125,8 @@
     e.height = height;
     head = e;
     // Start tracking image status.
-    target.checkImage(image, width, height, e);
+    int flags = target.checkImage(image, width, height, e);
+    e.imageUpdate(image, flags, -1, -1, width, height);
   }
 
   public boolean checkAll()

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]