Author: tack
Date: Thu Mar  1 18:04:43 2007
New Revision: 2532

Modified:
   trunk/imlib2/src/imlib2.c

Log:
More detailed exceptions on image creation failure.


Modified: trunk/imlib2/src/imlib2.c
==============================================================================
--- trunk/imlib2/src/imlib2.c   (original)
+++ trunk/imlib2/src/imlib2.c   Thu Mar  1 18:04:43 2007
@@ -83,6 +83,10 @@
                 data = NULL;
             }
         }
+        if (!bytes) {
+            PyErr_Format(PyExc_ValueError, "Image data address is null");
+            return NULL;
+        }
 
         if (!strcmp(from_format, "BGRA")) {
             if (copy)
@@ -94,19 +98,26 @@
             image = imlib_create_image_using_copied_data(w, h, bytes);
             free(bytes);
         }
+
+        if (!image) {
+            PyErr_Format(PyExc_RuntimeError, "Could not create %dx%d image 
(format=%s data=%p, copy=%d)",
+                        w, h, from_format, bytes, copy);
+            return NULL;
+        }
+
         imlib_context_set_image(image);
         if (strlen(from_format) == 4)
             imlib_image_set_has_alpha(1);
     } else {
         image = imlib_create_image(w, h);
+        if (!image) {
+            PyErr_Format(PyExc_RuntimeError, "Could not allocate new %dx%d 
image", w, h);
+            return NULL;
+        }
         imlib_context_set_image(image);
         imlib_image_set_has_alpha(1);
         imlib_image_clear_color(0, 0, 0, 0);
     }
-    if (!image) {
-        PyErr_Format(PyExc_RuntimeError, "Failed to create image");
-        return NULL;
-    }
 
     o = PyObject_NEW(Image_PyObject, &Image_PyObject_Type);
     o->image = image;

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to