[shotwell] direct: Fix crash when dismissing modifications



commit 77514d6960f563e1cb79f8510e123ee49461d24d
Author: Jens Georg <mail jensge org>
Date:   Tue Nov 6 23:30:55 2018 +0100

    direct: Fix crash when dismissing modifications
    
    Fixes obscure crash on g_menu_model_get_n_items seen in various
    downstream crash collectors, e.g.
    
    https://retrace.fedoraproject.org/faf/reports/2020125/
    https://bugs.launchpad.net/ubuntu/+source/shotwell/+bug/1723973

 src/Photo.vala                  | 16 ++++++----------
 src/direct/DirectPhotoPage.vala |  8 ++++----
 2 files changed, 10 insertions(+), 14 deletions(-)
---
diff --git a/src/Photo.vala b/src/Photo.vala
index 0d8e955d..ae0f489c 100644
--- a/src/Photo.vala
+++ b/src/Photo.vala
@@ -429,7 +429,7 @@ public abstract class Photo : PhotoSource, Dateable {
                 
                 // need to remove all transformations as they're keyed to the editable's
                 // coordinate system
-                internal_remove_all_transformations(false);
+                remove_all_transformations(false);
             }
         }
         
@@ -1519,7 +1519,7 @@ public abstract class Photo : PhotoSource, Dateable {
             row.master = original_master;
             row.master.copy_from(reimport_state.row.master);
             if (!reimport_state.metadata_only)
-                internal_remove_all_transformations(false);
+                remove_all_transformations(false);
         }
         
         if (reimport_state.metadata != null)
@@ -1596,7 +1596,7 @@ public abstract class Photo : PhotoSource, Dateable {
             lock (row) {
                 editable = reimport_state.backing_state;
                 set_orientation(reimport_state.backing_state.original_orientation);
-                internal_remove_all_transformations(false);
+                remove_all_transformations(false);
             }
         } else {
             set_orientation(reimport_state.backing_state.original_orientation);
@@ -2820,11 +2820,7 @@ public abstract class Photo : PhotoSource, Dateable {
         return committed;
     }
     
-    public void remove_all_transformations() {
-        internal_remove_all_transformations(true);
-    }
-    
-    private void internal_remove_all_transformations(bool notify) {
+    public void remove_all_transformations(bool notify = true) {
         bool is_altered = false;
         lock (row) {
             is_altered = PhotoTable.get_instance().remove_all_transformations(row.photo_id);
@@ -3907,7 +3903,7 @@ public abstract class Photo : PhotoSource, Dateable {
         // transformations are in the master's coordinate system, not the editable's ... don't 
         // notify photo is altered *yet* because update_editable will notify, and want to avoid 
         // stacking them up
-        internal_remove_all_transformations(false);
+        remove_all_transformations(false);
         update_editable(false, file_format.create_reader(file.get_path()));
     }
     
@@ -4077,7 +4073,7 @@ public abstract class Photo : PhotoSource, Dateable {
         }
         
         if (remove_transformations)
-            internal_remove_all_transformations(false);
+            remove_all_transformations(false);
         
         if (has_editable) {
             notify_baseline_replaced();
diff --git a/src/direct/DirectPhotoPage.vala b/src/direct/DirectPhotoPage.vala
index 4dddc00f..2b7fa258 100644
--- a/src/direct/DirectPhotoPage.vala
+++ b/src/direct/DirectPhotoPage.vala
@@ -301,7 +301,7 @@ public class DirectPhotoPage : EditingHostPage {
         base.update_actions(selected_count, count);
     }
     
-    private bool check_ok_to_close_photo(Photo? photo) {
+    private bool check_ok_to_close_photo(Photo? photo, bool notify = true) {
         // Means we failed to load the photo for some reason. Do not block
         // shutdown
         if (photo == null)
@@ -313,7 +313,7 @@ public class DirectPhotoPage : EditingHostPage {
         if (drop_if_dirty) {
             // need to remove transformations, or else they stick around in memory (reappearing
             // if the user opens the file again)
-            photo.remove_all_transformations();
+            photo.remove_all_transformations(notify);
             
             return true;
         }
@@ -326,7 +326,7 @@ public class DirectPhotoPage : EditingHostPage {
             _("Close _without Saving"));
 
         if (response == Gtk.ResponseType.YES)
-            photo.remove_all_transformations();
+            photo.remove_all_transformations(notify);
         else if (response == Gtk.ResponseType.NO) {
             if (is_writeable)
                 save(photo.get_file(), 0, ScaleConstraint.ORIGINAL, Jpeg.Quality.HIGH,
@@ -342,7 +342,7 @@ public class DirectPhotoPage : EditingHostPage {
     }
     
     public bool check_quit() {
-        return check_ok_to_close_photo(get_photo());
+        return check_ok_to_close_photo(get_photo(), false);
     }
     
     protected override bool confirm_replace_photo(Photo? old_photo, Photo new_photo) {


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