summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntónio Fernandes <antoniof@gnome.org>2021-02-05 16:14:38 +0000
committerOndrej Holy <oholy@redhat.com>2021-03-12 15:07:07 +0000
commit13de21b47fac39fcdcb2a72990d4a8b04a870bd2 (patch)
treec1ded5300b273836028fcade7fef0c4423454096
parent699cc7d04124d0a7bc54c80460fa2ea042e817d6 (diff)
downloadnautilus-13de21b47fac39fcdcb2a72990d4a8b04a870bd2.tar.gz
window: Add weak reference to the active slot
We used to explicitly set the active slot when closing a tab. However, we now let GtkNotebook pick the next tab, and wait for ::switch-tab to set the active_slot field to the one GtkNotebook picked, thanks to commit 475684ac9e556b144da594bf25581560d4fa5a7f. However, if the closed tab was the only tab in this window, then ::switch-tab is never called, so active_slot becomes a dangling pointer, crashing the application when trying to close the window. Use a weak reference to ensure the pointer is set to NULL in that case. Fixes https://gitlab.gnome.org/GNOME/nautilus/-/issues/1759
-rw-r--r--src/nautilus-window.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 73fe741b7..e4294f6dd 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -106,7 +106,7 @@ struct _NautilusWindow
* Both of them may never be NULL.
*/
GList *slots;
- NautilusWindowSlot *active_slot;
+ NautilusWindowSlot *active_slot; /* weak reference */
GtkWidget *content_paned;
@@ -2291,7 +2291,7 @@ nautilus_window_destroy (GtkWidget *object)
/* the slots list should now be empty */
g_assert (window->slots == NULL);
- window->active_slot = NULL;
+ g_clear_weak_pointer (&window->active_slot);
g_clear_signal_handler (&window->bookmarks_id, nautilus_application_get_bookmarks (application));
@@ -2447,7 +2447,7 @@ nautilus_window_set_active_slot (NautilusWindow *window,
nautilus_toolbar_set_window_slot (NAUTILUS_TOOLBAR (window->toolbar), NULL);
}
- window->active_slot = new_slot;
+ g_set_weak_pointer (&window->active_slot, new_slot);
/* make new slot active, if it exists */
if (new_slot)