Commit f6e0d5d3 authored by Eric Gregory's avatar Eric Gregory

#3129 fixed segfault when opening photo with missing backing file

parent c0dbe8e6
...@@ -912,6 +912,9 @@ public class CheckerboardLayout : Gtk.DrawingArea { ...@@ -912,6 +912,9 @@ public class CheckerboardLayout : Gtk.DrawingArea {
} }
public CheckerboardItem? get_item_at_pixel(double xd, double yd) { public CheckerboardItem? get_item_at_pixel(double xd, double yd) {
if (null == item_rows)
return null;
int x = (int) xd; int x = (int) xd;
int y = (int) yd; int y = (int) yd;
......
...@@ -982,7 +982,7 @@ public abstract class EditingHostPage : SinglePhotoPage { ...@@ -982,7 +982,7 @@ public abstract class EditingHostPage : SinglePhotoPage {
replace_photo(photo); replace_photo(photo);
} }
protected virtual void update_ui(Photo photo, bool missing) { protected virtual void update_ui(bool missing) {
bool sensitivity = !missing; bool sensitivity = !missing;
rotate_button.sensitive = sensitivity; rotate_button.sensitive = sensitivity;
...@@ -1025,7 +1025,7 @@ public abstract class EditingHostPage : SinglePhotoPage { ...@@ -1025,7 +1025,7 @@ public abstract class EditingHostPage : SinglePhotoPage {
if (photo == null) if (photo == null)
return; return;
update_ui(photo, missing); update_ui(missing);
if (photo_missing) { if (photo_missing) {
try { try {
...@@ -1095,7 +1095,7 @@ public abstract class EditingHostPage : SinglePhotoPage { ...@@ -1095,7 +1095,7 @@ public abstract class EditingHostPage : SinglePhotoPage {
swapped = null; swapped = null;
// reset flags // reset flags
set_photo_missing(false); set_photo_missing(!new_photo.get_file().query_exists());
pixbuf_dirty = true; pixbuf_dirty = true;
// it's possible for this to be called prior to the page being realized, however, the // it's possible for this to be called prior to the page being realized, however, the
...@@ -1700,8 +1700,11 @@ public abstract class EditingHostPage : SinglePhotoPage { ...@@ -1700,8 +1700,11 @@ public abstract class EditingHostPage : SinglePhotoPage {
} }
if (photo_missing && has_photo()) { if (photo_missing && has_photo()) {
Gdk.cairo_set_source_color(ctx, canvas.style.black);
ctx.rectangle(0, 0, get_surface_dim().width, get_surface_dim().height);
ctx.fill();
ctx.paint();
draw_message(_("Photo source file missing: %s").printf(get_photo().get_file().get_path())); draw_message(_("Photo source file missing: %s").printf(get_photo().get_file().get_path()));
return; return;
} }
...@@ -2636,7 +2639,7 @@ public class LibraryPhotoPage : EditingHostPage { ...@@ -2636,7 +2639,7 @@ public class LibraryPhotoPage : EditingHostPage {
} }
} }
protected override void update_ui(Photo photo, bool missing) { protected override void update_ui(bool missing) {
bool sensitivity = !missing; bool sensitivity = !missing;
set_action_sensitive("SendTo", sensitivity); set_action_sensitive("SendTo", sensitivity);
...@@ -2675,7 +2678,7 @@ public class LibraryPhotoPage : EditingHostPage { ...@@ -2675,7 +2678,7 @@ public class LibraryPhotoPage : EditingHostPage {
set_action_sensitive("SetBackground", sensitivity); set_action_sensitive("SetBackground", sensitivity);
base.update_ui(photo, missing); base.update_ui(missing);
} }
protected override void notify_photo_backing_missing(Photo photo, bool missing) { protected override void notify_photo_backing_missing(Photo photo, bool missing) {
...@@ -3554,7 +3557,7 @@ public class DirectPhotoPage : EditingHostPage { ...@@ -3554,7 +3557,7 @@ public class DirectPhotoPage : EditingHostPage {
get_command_manager().reset(); get_command_manager().reset();
} }
protected override void update_ui(Photo photo, bool missing) { protected override void update_ui(bool missing) {
bool sensitivity = !missing; bool sensitivity = !missing;
set_action_sensitive("Save", sensitivity); set_action_sensitive("Save", sensitivity);
...@@ -3587,7 +3590,7 @@ public class DirectPhotoPage : EditingHostPage { ...@@ -3587,7 +3590,7 @@ public class DirectPhotoPage : EditingHostPage {
set_action_sensitive("SetBackground", has_photo() && !get_photo_missing()); set_action_sensitive("SetBackground", has_photo() && !get_photo_missing());
base.update_ui(photo, missing); base.update_ui(missing);
} }
protected override void update_actions(int selected_count, int count) { protected override void update_actions(int selected_count, int count) {
......
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