gtk/placessidebar: Connect row object to popover map/unmap

nautilus-bookmark-list is sending changed signals in the same callstack
where the rename button is pressed, which is before the popover is
unmapped. And thus is causing the sidebar to rebuild the rows, destroying
the row before the unmap callback is called on the row.

Change the binding of the signal to the lifetime of the row instead of
binding it to the sidebar.

This fixes a crash when renaming bookmarks.
This commit is contained in:
Khalid Abu Shawarib 2024-06-16 02:29:13 +03:00
parent 8ba056abd1
commit dcbd17359b

View file

@ -2021,23 +2021,27 @@ update_popover_shadowing (GtkWidget *row,
}
static void
set_prelight (NautilusGtkPlacesSidebar *sidebar)
set_prelight (NautilusGtkSidebarRow *row)
{
update_popover_shadowing (GTK_WIDGET (sidebar->context_row), TRUE);
update_popover_shadowing (GTK_WIDGET (row), TRUE);
}
static void
unset_prelight (NautilusGtkPlacesSidebar *sidebar)
unset_prelight (NautilusGtkSidebarRow *row)
{
update_popover_shadowing (GTK_WIDGET (sidebar->context_row), FALSE);
update_popover_shadowing (GTK_WIDGET (row), FALSE);
}
static void
setup_popover_shadowing (GtkWidget *popover,
NautilusGtkPlacesSidebar *sidebar)
{
g_signal_connect_swapped (popover, "map", G_CALLBACK (set_prelight), sidebar);
g_signal_connect_swapped (popover, "unmap", G_CALLBACK (unset_prelight), sidebar);
g_signal_connect_object (popover, "map",
G_CALLBACK (set_prelight), sidebar->context_row,
G_CONNECT_SWAPPED);
g_signal_connect_object (popover, "unmap",
G_CALLBACK (unset_prelight), sidebar->context_row,
G_CONNECT_SWAPPED);
}
static void
@ -3016,6 +3020,7 @@ show_row_popover (NautilusGtkSidebarRow *row,
g_clear_pointer (&sidebar->popover, gtk_widget_unparent);
sidebar->context_row = row;
create_row_popover (sidebar, row);
if ((x == -1 && y == -1) ||
@ -3029,7 +3034,6 @@ show_row_popover (NautilusGtkSidebarRow *row,
&(GdkRectangle){p_in_sidebar.x, p_in_sidebar.y, 0, 0});
}
sidebar->context_row = row;
gtk_popover_popup (GTK_POPOVER (sidebar->popover));
g_object_unref (sidebar);