From 4c55f1f28e8df2e108c56b91ffbc18a9a279df53 Mon Sep 17 00:00:00 2001 From: Jaeheon Shim Date: Fri, 12 Dec 2025 04:56:33 -0500 Subject: [PATCH] Block ev_sidebar_tree_selection_changed handler during sidebar destroy to avoid accidentally rewriting the last viewed page number. --- shell/ev-sidebar-thumbnails.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/shell/ev-sidebar-thumbnails.c b/shell/ev-sidebar-thumbnails.c index 5656c14a..cffbd41a 100644 --- a/shell/ev-sidebar-thumbnails.c +++ b/shell/ev-sidebar-thumbnails.c @@ -1217,9 +1217,23 @@ static void ev_sidebar_thumbnails_clear_model (EvSidebarThumbnails *sidebar_thumbnails) { EvSidebarThumbnailsPrivate *priv = sidebar_thumbnails->priv; + GtkTreeSelection *selection = NULL; + + /* Block ev_sidebar_tree_selection_changed handler while clearing the model. + * gtk_list_store_clear() causes the GtkTreeSelection to emit "changed", + * which incorrectly updates the document page when the sidebar is destroyed. + */ + if (priv->tree_view && GTK_IS_TREE_VIEW (priv->tree_view)) { + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->tree_view)); + g_signal_handlers_block_by_func (selection, ev_sidebar_tree_selection_changed, sidebar_thumbnails); + } gtk_tree_model_foreach (GTK_TREE_MODEL (priv->list_store), ev_sidebar_thumbnails_clear_job, sidebar_thumbnails); gtk_list_store_clear (priv->list_store); + + if (selection) { + g_signal_handlers_unblock_by_func (selection, ev_sidebar_tree_selection_changed, sidebar_thumbnails); + } } static gboolean