[shotwell] Better error handling with Photo.get_prefetched_copy()



commit cfcb002cdf431a0564e1d071e0f0fcd7bc346876
Author: Jim Nelson <jim yorba org>
Date:   Tue Sep 9 13:40:58 2014 -0700

    Better error handling with Photo.get_prefetched_copy()
    
    Throw an Error rather than return null, which wasn't being handled
    correctly in all cases.

 src/Photo.vala     |   11 +++++------
 src/PhotoPage.vala |   12 ++++++------
 2 files changed, 11 insertions(+), 12 deletions(-)
---
diff --git a/src/Photo.vala b/src/Photo.vala
index ac324fe..34b2676 100644
--- a/src/Photo.vala
+++ b/src/Photo.vala
@@ -3225,14 +3225,15 @@ public abstract class Photo : PhotoSource, Dateable {
      *
      * @return A Pixbuf with the image data from unmodified_precached.
      */
-    public Gdk.Pixbuf? get_prefetched_copy() {
+    public Gdk.Pixbuf get_prefetched_copy() throws Error {
         lock (unmodified_precached) {
             if (unmodified_precached == null) {
                 try {
                     populate_prefetched();
                 } catch (Error e) {
-                    warning("raw pixbuf for %s could not be loaded", this.to_string());
-                    return null;
+                    message("pixbuf for %s could not be loaded: %s", to_string(), e.message);
+                    
+                    throw e;
                 }
             }
 
@@ -3331,12 +3332,10 @@ public abstract class Photo : PhotoSource, Dateable {
         populate_prefetched();
 
         Gdk.Pixbuf pixbuf = get_prefetched_copy();
-
+        
         // remember to delete the cached copy if it isn't being used.
         secs_since_access.start();
         debug("pipeline being run against %s, timer restarted.", this.to_string());
-
-        assert(pixbuf != null);
         
         //
         // Image transformation pipeline
diff --git a/src/PhotoPage.vala b/src/PhotoPage.vala
index 4a08adc..8db84a1 100644
--- a/src/PhotoPage.vala
+++ b/src/PhotoPage.vala
@@ -1386,13 +1386,13 @@ public abstract class EditingHostPage : SinglePhotoPage {
     }
 
     private void swap_in_original() {
-        Gdk.Pixbuf? original;
-        
-        original =
-            get_photo().get_original_orientation().rotate_pixbuf(get_photo().get_prefetched_copy());
-        
-        if (original == null)
+        Gdk.Pixbuf original;
+        try {
+            original = get_photo().get_original_orientation().rotate_pixbuf(
+                get_photo().get_prefetched_copy());
+        } catch (Error err) {
             return;
+        }
         
         // store what's currently displayed only for the duration of the shift pressing
         swapped = get_unscaled_pixbuf();


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