MenuButton: Drop ref to Popover on its ::destroy

Otherwise, if the Popover is destroyed before the MenuButton, the latter
still had a non-NULL but invalid instance and tried to use it in dispose

Close https://gitlab.gnome.org/GNOME/gtk/issues/199
This commit is contained in:
Daniel Boles 2018-04-22 14:52:27 +01:00
parent 1d636dc8d4
commit caa9255dd3

View File

@ -1086,6 +1086,12 @@ gtk_menu_button_get_use_popover (GtkMenuButton *menu_button)
return priv->use_popover;
}
static void
popover_destroy_cb (GtkMenuButton *menu_button)
{
gtk_menu_button_set_popover (menu_button, NULL);
}
/**
* gtk_menu_button_set_popover:
* @menu_button: a #GtkMenuButton
@ -1127,6 +1133,8 @@ gtk_menu_button_set_popover (GtkMenuButton *menu_button,
gtk_popover_set_relative_to (GTK_POPOVER (priv->popover), GTK_WIDGET (menu_button));
g_signal_connect_swapped (priv->popover, "closed",
G_CALLBACK (menu_deactivate_cb), menu_button);
g_signal_connect_swapped (priv->popover, "destroy",
G_CALLBACK (popover_destroy_cb), menu_button);
update_popover_direction (menu_button);
gtk_style_context_remove_class (gtk_widget_get_style_context (GTK_WIDGET (menu_button)), "menu-button");
}