[eog] EogWindow: Fix warning when deleting last image



commit 93be055d15eb4e197edc8ca54d50fc6c2c7b4463
Author: Felix Riemann <friemann gnome org>
Date:   Fri Jan 3 19:54:53 2020 +0100

    EogWindow: Fix warning when deleting last image
    
    The code that would select the next image needs to check first
    if there's actually an image to select to avoid emitting
    a critical warning. Fixes 49a07699.

 src/eog-window.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/src/eog-window.c b/src/eog-window.c
index f225e8ae..e79bca9c 100644
--- a/src/eog-window.c
+++ b/src/eog-window.c
@@ -5172,10 +5172,12 @@ eog_window_list_store_image_removed (GtkTreeModel *tree_model,
 {
        EogWindow *window = EOG_WINDOW (user_data);
        EogWindowPrivate *priv = window->priv;
+       gint n_images = eog_list_store_length (priv->store);
 
-       if (eog_thumb_view_get_n_selected (EOG_THUMB_VIEW (priv->thumbview)) == 0) {
+       if (eog_thumb_view_get_n_selected (EOG_THUMB_VIEW (priv->thumbview)) == 0
+           && n_images > 0) {
                gint pos = MIN (gtk_tree_path_get_indices (path)[0],
-                               eog_list_store_length (priv->store) - 1);
+                               n_images - 1);
                EogImage *image = eog_list_store_get_image_by_pos (priv->store, pos);
 
                if (image != NULL) {


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