classpath-patches
[Top][All Lists]
Advanced

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

[cp-patches] FYI: Make MediaTRacker handle Images that didn't properly l


From: Mark Wielaard
Subject: [cp-patches] FYI: Make MediaTRacker handle Images that didn't properly load
Date: Tue, 12 Jul 2005 11:15:00 +0200

Hi,

In MediaTracker we didn't correctly handle Images that were already
loaded, but that actually failed to load correctly. In such a case
prepareImage() will return false immediately, but the ImageObserver will
never be called. So we need an extra call to checkImage() to explicitly
grab the status. And since checkImage() itself doesn't in itself try to
load the image, we do still need the prepareImage() call to kick off the
loading.

2005-07-12  Mark Wielaard  <address@hidden>

        * java/awt/MediaTracker.java (checkAll): Set and check status of
        MediaEntry with checkImage() if prepareImage() returns false.
        (statusAll): Likewise.
        (checkID): Likewise.
        (statusID): Likewise.

This makes our swing work again when the Look and Feel references images
that don't exist.

Thanks to Sven, Stephane and Thomas for walking me through the Image
loading maze.

Committed,

Mark

Index: java/awt/MediaTracker.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/awt/MediaTracker.java,v
retrieving revision 1.17
diff -u -r1.17 MediaTracker.java
--- java/awt/MediaTracker.java  6 Jul 2005 08:15:17 -0000       1.17
+++ java/awt/MediaTracker.java  12 Jul 2005 09:12:00 -0000
@@ -241,15 +241,24 @@
           {
             if (load && ((e.status & LOADING) == 0))
               {
-                e.status = LOADING;
-                result = false;
-                boolean complete = target.prepareImage(e.image, e);
-                if (complete)
-                  {
-                    e.status = COMPLETE;
-                    result = true;
-                  }
-              }
+               if (target.prepareImage(e.image, e))
+                 e.status = COMPLETE;
+               else
+                 {
+                   e.status = LOADING;
+                   int flags = target.checkImage(e.image, e);
+                   if ((flags & ImageObserver.ABORT) != 0)
+                     e.status = ABORTED;
+                   else if ((flags & ImageObserver.ERROR) != 0)
+                     e.status = ERRORED;
+                   else if ((flags & ImageObserver.ALLBITS) != 0)
+                     e.status = COMPLETE;
+                 }
+               boolean complete = (e.status
+                                   & (COMPLETE | ABORTED | ERRORED)) != 0;
+               if (!complete)
+                 result = false;
+             }
             else
               result = false;
           }
@@ -373,11 +382,19 @@
       {
         if (load && e.status == 0)
           {
-            boolean complete = target.prepareImage(e.image, e);
-            if (complete)
+            if (target.prepareImage(e.image, e))
               e.status = COMPLETE;
             else
-              e.status = LOADING;
+             {
+                e.status = LOADING;
+                int flags = target.checkImage(e.image, e);
+               if ((flags & ImageObserver.ABORT) != 0)
+                 e.status = ABORTED;
+               else if ((flags & ImageObserver.ERROR) != 0)
+                 e.status = ERRORED;
+               else if ((flags & ImageObserver.ALLBITS) != 0)
+                 e.status = COMPLETE;
+             }
           }
         result |= e.status;
         e = e.next;
@@ -422,13 +439,22 @@
             if (load && ((e.status & LOADING) == 0))
               {
                 e.status = LOADING;
-                result = false;
-                boolean complete = target.prepareImage(e.image, e);
-                if (complete)
-                  {
-                    e.status = COMPLETE;
-                    result = true;
-                  }
+               if (target.prepareImage(e.image, e))
+                 e.status = COMPLETE;
+               else
+                 {
+                   int flags = target.checkImage(e.image, e);
+                   if ((flags & ImageObserver.ABORT) != 0)
+                     e.status = ABORTED;
+                   else if ((flags & ImageObserver.ERROR) != 0)
+                     e.status = ERRORED;
+                   else if ((flags & ImageObserver.ALLBITS) != 0)
+                     e.status = COMPLETE;
+                 }
+               boolean complete = (e.status
+                                   & (COMPLETE | ABORTED | ERRORED)) != 0;
+               if (!complete)
+                 result = false;
               }
             else
               result = false;
@@ -567,11 +593,19 @@
           {
             if (load && e.status == 0)
               {
-                boolean complete = target.prepareImage(e.image, e);
-                if (complete)
+               if (target.prepareImage(e.image, e))
                   e.status = COMPLETE;
-                else
-                  e.status = LOADING;
+               else
+                 {
+                   e.status = LOADING;
+                   int flags = target.checkImage(e.image, e);
+                   if ((flags & ImageObserver.ABORT) != 0)
+                     e.status = ABORTED;
+                   else if ((flags & ImageObserver.ERROR) != 0)
+                     e.status = ERRORED;
+                   else if ((flags & ImageObserver.ALLBITS) != 0)
+                     e.status = COMPLETE;
+                 }
               }
             result |= e.status;
           }

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


reply via email to

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