[ocrfeeder] widgetModeler: Prevent problems when updating the background image



commit bc7b8bdf910d2475c2ff78232b84b10a529f8fbb
Author: Joaquim Rocha <jrocha igalia com>
Date:   Thu Jul 1 15:26:53 2010 +0200

    widgetModeler: Prevent problems when updating the background image
    
    Verify image's path and catch exceptions when updating the background image

 studio/widgetModeler.py |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/studio/widgetModeler.py b/studio/widgetModeler.py
index c0ce388..cf8641f 100644
--- a/studio/widgetModeler.py
+++ b/studio/widgetModeler.py
@@ -326,7 +326,13 @@ class ImageReviewer:
 
     def updateBackgroundImage(self, image_path):
         self.path_to_image = image_path
-        self.image_pixbuf = gtk.gdk.pixbuf_new_from_file(self.path_to_image)
+        if not os.path.exists(self.path_to_image):
+            return
+        try:
+            self.image_pixbuf = gtk.gdk.pixbuf_new_from_file(self.path_to_image)
+        except Exception, exception:
+            debug(exception.message)
+            return
         self.selectable_boxes_area.setBackgroundImage(self.path_to_image)
 
     def updateBoxesColors(self):



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