mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-11-05 16:04:31 +00:00
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 475684ac9e
.
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
This commit is contained in:
parent
699cc7d041
commit
13de21b47f
1 changed files with 3 additions and 3 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue