summaryrefslogtreecommitdiff
path: root/gtk/gtkpopovermenu.c
diff options
context:
space:
mode:
Diffstat (limited to 'gtk/gtkpopovermenu.c')
-rw-r--r--gtk/gtkpopovermenu.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/gtk/gtkpopovermenu.c b/gtk/gtkpopovermenu.c
index 447d21171a..dc3212b533 100644
--- a/gtk/gtkpopovermenu.c
+++ b/gtk/gtkpopovermenu.c
@@ -184,7 +184,10 @@ gtk_popover_menu_set_active_item (GtkPopoverMenu *menu,
if (menu->active_item != item)
{
if (menu->active_item)
- gtk_widget_unset_state_flags (menu->active_item, GTK_STATE_FLAG_SELECTED);
+ {
+ gtk_widget_unset_state_flags (menu->active_item, GTK_STATE_FLAG_SELECTED);
+ g_object_remove_weak_pointer (G_OBJECT (menu->active_item), (gpointer *)&menu->active_item);
+ }
menu->active_item = item;
@@ -192,6 +195,8 @@ gtk_popover_menu_set_active_item (GtkPopoverMenu *menu,
{
GtkWidget *popover;
+ g_object_add_weak_pointer (G_OBJECT (menu->active_item), (gpointer *)&menu->active_item);
+
gtk_widget_set_state_flags (menu->active_item, GTK_STATE_FLAG_SELECTED, FALSE);
if (GTK_IS_MODEL_BUTTON (item))
g_object_get (item, "popover", &popover, NULL);
@@ -277,6 +282,12 @@ gtk_popover_menu_dispose (GObject *object)
{
GtkPopoverMenu *popover = GTK_POPOVER_MENU (object);
+ if (popover->active_item)
+ {
+ g_object_remove_weak_pointer (G_OBJECT (popover->active_item), (gpointer *)&popover->active_item);
+ popover->active_item = NULL;
+ }
+
g_clear_object (&popover->model);
G_OBJECT_CLASS (gtk_popover_menu_parent_class)->dispose (object);