Commit b5a223f6 authored by Jim Nelson's avatar Jim Nelson

Fixed a bug in photo removal.

parent 55ee6849
......@@ -181,7 +181,12 @@ public class CollectionLayout : Gtk.Layout {
public void remove_item(LayoutItem item) {
items.remove(item);
remove(item);
// this situation can happen if the item was added but the page not yet rendered ... because
// CollectionLayout doens't know where to place the item until refresh(), that's when it's
// initially added
if (item.parent != null)
remove(item);
}
public LayoutItem? get_item_at(double xd, double yd) {
......
......@@ -203,25 +203,8 @@ public class CollectionPage : CheckerboardPage {
}
private void on_photo_removed(Photo photo) {
debug("on_photo_removed");
debug("%s on_photo_removed", get_name());
bool removed = remove_photo(photo);
assert(removed);
}
private void on_photo_altered(Photo photo) {
debug("on_photo_altered");
// the thumbnail is only going to reload a low-quality interp, so schedule improval
schedule_thumbnail_improval();
// since the geometry might have changed, refresh the layout
if (in_view)
refresh();
}
// This does not remove the photo from the system, only from this layout
public bool remove_photo(Photo photo) {
Thumbnail found = null;
foreach (LayoutItem item in get_items()) {
Thumbnail thumbnail = (Thumbnail) item;
......@@ -232,10 +215,22 @@ public class CollectionPage : CheckerboardPage {
}
}
if (found != null)
// have to remove outside of iterator
if (found != null) {
debug("Removing %s from %s", photo.to_string(), get_name());
remove_item(found);
}
}
private void on_photo_altered(Photo photo) {
debug("on_photo_altered");
return (found != null);
// the thumbnail is only going to reload a low-quality interp, so schedule improval
schedule_thumbnail_improval();
// since the geometry might have changed, refresh the layout
if (in_view)
refresh();
}
public int increase_thumb_size() {
......
......@@ -287,16 +287,15 @@ public abstract class CheckerboardPage : Page {
}
public void remove_item(LayoutItem item) {
selected_items.remove(item);
layout.remove_item(item);
}
public int remove_selected() {
int count = selected_items.size;
foreach (LayoutItem item in selected_items) {
foreach (LayoutItem item in selected_items)
layout.remove_item(item);
layout.items.remove(item);
}
selected_items.clear();
......@@ -307,7 +306,6 @@ public abstract class CheckerboardPage : Page {
int count = layout.items.size;
layout.clear();
layout.items.clear();
selected_items.clear();
return 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