mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-14 20:51:07 +00:00
main: Keep the target widget alive
We are passing the event to the tooltip handle_event function at the very end. Unfortunately, the target_widget may have already died at that point. We prevent that by taking a ref during propagage_event, but the tooltip code was outside of that. Keep a ref until the very end ot prevent crashes.
This commit is contained in:
parent
028bccc188
commit
dff5986ec2
@ -1733,6 +1733,8 @@ gtk_main_do_event (GdkEvent *event)
|
||||
gtk_widget_is_ancestor (target_widget, grab_widget)))
|
||||
grab_widget = target_widget;
|
||||
|
||||
g_object_ref (target_widget);
|
||||
|
||||
/* Not all events get sent to the grabbing widget.
|
||||
* The delete, destroy, expose, focus change and resize
|
||||
* events still get sent to the event widget because
|
||||
@ -1746,7 +1748,6 @@ gtk_main_do_event (GdkEvent *event)
|
||||
switch ((guint)gdk_event_get_event_type (event))
|
||||
{
|
||||
case GDK_DELETE:
|
||||
g_object_ref (target_widget);
|
||||
if (!gtk_window_group_get_current_grab (window_group) ||
|
||||
GTK_WIDGET (gtk_widget_get_root (gtk_window_group_get_current_grab (window_group))) == target_widget)
|
||||
{
|
||||
@ -1754,7 +1755,6 @@ gtk_main_do_event (GdkEvent *event)
|
||||
!gtk_window_emit_close_request (GTK_WINDOW (target_widget)))
|
||||
gtk_window_destroy (GTK_WINDOW (target_widget));
|
||||
}
|
||||
g_object_unref (target_widget);
|
||||
break;
|
||||
|
||||
case GDK_FOCUS_CHANGE:
|
||||
@ -1810,6 +1810,8 @@ gtk_main_do_event (GdkEvent *event)
|
||||
|
||||
_gtk_tooltip_handle_event (target_widget, event);
|
||||
|
||||
g_object_unref (target_widget);
|
||||
|
||||
cleanup:
|
||||
tmp_list = current_events;
|
||||
current_events = g_list_remove_link (current_events, tmp_list);
|
||||
|
Loading…
Reference in New Issue
Block a user