[gthumb] Fixed crash when selecting other images after deleting
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] Fixed crash when selecting other images after deleting
- Date: Sun, 13 Sep 2020 06:57:15 +0000 (UTC)
commit da2a196b9d2d991fd649c9ed94071938da901b48
Author: Paolo Bacchilega <paobac src gnome org>
Date: Sun Sep 13 08:46:59 2020 +0200
Fixed crash when selecting other images after deleting
This only happened when selecting images with a range select
(shift + mouse click) after deleting the last images in a list.
The last_selected_pos value was not updated after deleting or adding
files to the list.
Closes #126
gthumb/gth-grid-view.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
---
diff --git a/gthumb/gth-grid-view.c b/gthumb/gth-grid-view.c
index 83fc300ae..1b2bdffe5 100644
--- a/gthumb/gth-grid-view.c
+++ b/gthumb/gth-grid-view.c
@@ -2187,6 +2187,13 @@ model_row_deleted_cb (GtkTreeModel *tree_model,
else if (pos == self->priv->focused_item)
self->priv->focused_item = -1;
+ /* update the last selected position */
+
+ if (pos < self->priv->last_selected_pos)
+ self->priv->last_selected_pos--;
+ else if (pos == self->priv->last_selected_pos)
+ self->priv->last_selected_pos = -1;
+
/* relayout from the minimum changed position */
_gth_grid_view_queue_relayout_from_position (self, pos);
@@ -2238,6 +2245,11 @@ model_row_inserted_cb (GtkTreeModel *tree_model,
if (pos <= self->priv->focused_item)
self->priv->focused_item++;
+ /* update the last selected position */
+
+ if (pos <= self->priv->last_selected_pos)
+ self->priv->last_selected_pos++;
+
/* relayout from the minimum changed position */
_gth_grid_view_queue_relayout_from_position (self, pos);
@@ -2666,7 +2678,7 @@ _gth_grid_view_select_range (GthGridView *self,
}
for (scan = g_list_nth (self->priv->items, a);
- a <= b;
+ (a <= b) && (scan != NULL);
a++, scan = scan->next)
{
GthGridViewItem *item = scan->data;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]