gnome-games r7964 - trunk/glchess/src/lib/scene/opengl



Author: rancell
Date: Wed Oct  8 04:08:13 2008
New Revision: 7964
URL: http://svn.gnome.org/viewvc/gnome-games?rev=7964&view=rev

Log:
Handle exceptions loading OpenGL textures (Bug #548916)

Modified:
   trunk/glchess/src/lib/scene/opengl/texture.py

Modified: trunk/glchess/src/lib/scene/opengl/texture.py
==============================================================================
--- trunk/glchess/src/lib/scene/opengl/texture.py	(original)
+++ trunk/glchess/src/lib/scene/opengl/texture.py	Wed Oct  8 04:08:13 2008
@@ -48,11 +48,17 @@
     def __loadPNG(self, fileName):
         """
         """
-        reader = png.Reader(fileName)
+        try:
+            reader = png.Reader(fileName)
+        except IOError, e:
+            print 'Error loading texture file: %s: %s' % (fileName, e.strerror)
+            self.__data = None
+            return
+
         try:
             (width, height, data, metaData) = reader.read()
         except png.Error, e:
-            print 'Error loading texture %s: %s' % (fileName, e.message)
+            print 'Error parsing PNG file %s: %s' % (fileName, e.message)
             self.__data = None
             return
         
@@ -71,7 +77,12 @@
         import Image
         
         # Load the image file
-        image = Image.open(fileName)
+        try:
+            image = Image.open(fileName)
+        except IOError, e:
+            print 'Error loading texture file: %s: %s' % (fileName, e.strerror)
+            self.__data = None
+            return            
 
         # Crop the image so it has height/width a multiple of 2
         width = image.size[0]



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