Commit 77514d69 authored by Jens Georg's avatar Jens Georg

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
parent 1f4532a1
......@@ -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();
......
......@@ -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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment