Fix #10496 crash on RMB in chooser item not the current selection

Use g_signal_connect_object to ensure object passed to handler
is not destroyed in the middle of the handler by knock-on signal handling.

Note there are comments about this in gimpcontainertreeview.c line 1592.
And similar code i.e. calls to gimp_container_view_get_container
that seem to be intended to solve but might actually also be susceptible.
Those calls in icon view throw CRITICALs during this issue.
But testing of the tree view (a list instead of a grid)
doesn't seem to crash, so leave well enough alone.
This commit is contained in:
bootchk 2023-12-28 08:56:36 -05:00 committed by Lloyd Konneker
parent 7d8495fdd2
commit 784cde7f14

View file

@ -343,9 +343,10 @@ gimp_container_icon_view_set_container (GimpContainerView *view,
icon_view);
}
g_signal_connect (icon_view->view, "button-press-event",
G_CALLBACK (gimp_container_icon_view_button_press),
icon_view);
g_signal_connect_object (icon_view->view, "button-press-event",
G_CALLBACK (gimp_container_icon_view_button_press),
icon_view,
G_CONNECT_DEFAULT);
}
parent_view_iface->set_container (view, container);
@ -664,8 +665,7 @@ gimp_container_icon_view_button_press (GtkWidget *widget,
if (! gimp_container_view_is_item_selected (container_view, renderer->viewable))
gimp_container_view_item_selected (container_view, renderer->viewable);
/* Show the context menu. */
if (gimp_container_view_get_container (container_view))
gimp_editor_popup_menu_at_pointer (GIMP_EDITOR (icon_view), (GdkEvent *) bevent);
gimp_editor_popup_menu_at_pointer (GIMP_EDITOR (icon_view), (GdkEvent *) bevent);
}
g_object_unref (renderer);