summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntónio Fernandes <antoniof@gnome.org>2021-02-05 16:14:38 +0000
committerAntónio Fernandes <antoniof@gnome.org>2021-02-27 15:53:44 +0000
commit0182308c1c85b0c9a0045ac6f74985649731e9d6 (patch)
treea83dea46917482e1c1e89240645539840ffbda4f
parente71091f5582f2228acba0fa4541ae2b0733271c2 (diff)
downloadnautilus-0182308c1c85b0c9a0045ac6f74985649731e9d6.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)