diff options
author | Lars Uebernickel <lars.uebernickel@canonical.com> | 2013-10-31 11:07:00 -0700 |
---|---|---|
committer | Lars Uebernickel <lars.uebernickel@canonical.com> | 2013-10-31 11:07:00 -0700 |
commit | 10c52b70e10255fdb68be71f6b28eb3cc1c50e46 (patch) | |
tree | 5c20bf6d98a7bbee660df51964d9a8b8ab00acd7 | |
parent | 28427a3e5e9669692172292abf7ed0d4fb712bb8 (diff) | |
download | ayatana-ido-10c52b70e10255fdb68be71f6b28eb3cc1c50e46.tar.gz ayatana-ido-10c52b70e10255fdb68be71f6b28eb3cc1c50e46.tar.bz2 ayatana-ido-10c52b70e10255fdb68be71f6b28eb3cc1c50e46.zip |
idoscalemenuitem: disconnect signal from parent
This fixes a crash: the widget installed a handler for the parent's hide
signal, but was destroyed before the parent without disconnecting the signal.
This patch also moves the connection into GktWidget.parent_set instead of
connecting to the notify signal.
-rw-r--r-- | src/idoscalemenuitem.c | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/src/idoscalemenuitem.c b/src/idoscalemenuitem.c index 9b933cc..fc39464 100644 --- a/src/idoscalemenuitem.c +++ b/src/idoscalemenuitem.c @@ -52,9 +52,8 @@ static void ido_scale_menu_item_primary_image_notify (GtkImage static void ido_scale_menu_item_secondary_image_notify (GtkImage *image, GParamSpec *pspec, IdoScaleMenuItem *item); -static void ido_scale_menu_item_notify (IdoScaleMenuItem *item, - GParamSpec *pspec, - gpointer user_data); +static void ido_scale_menu_item_parent_set (GtkWidget *item, + GtkWidget *previous_parent); static void update_packing (IdoScaleMenuItem *self, IdoScaleMenuItemStyle style); static void default_primary_clicked_handler (IdoScaleMenuItem *self); @@ -265,10 +264,6 @@ ido_scale_menu_item_constructed (GObject *object) G_CALLBACK (ido_scale_menu_item_toggle_size_allocate), NULL); - g_signal_connect (self, "notify", - G_CALLBACK (ido_scale_menu_item_notify), - NULL); - gtk_container_add (GTK_CONTAINER (self), hbox); gtk_widget_add_events (GTK_WIDGET(self), GDK_SCROLL_MASK); @@ -288,6 +283,7 @@ ido_scale_menu_item_class_init (IdoScaleMenuItemClass *item_class) widget_class->motion_notify_event = ido_scale_menu_item_motion_notify_event; widget_class->scroll_event = ido_scale_menu_item_scroll_event; widget_class->size_allocate = ido_scale_menu_item_size_allocate; + widget_class->parent_set = ido_scale_menu_item_parent_set; gobject_class->constructed = ido_scale_menu_item_constructed; gobject_class->set_property = ido_scale_menu_item_set_property; @@ -645,21 +641,18 @@ menu_hidden (GtkWidget *menu, } static void -ido_scale_menu_item_notify (IdoScaleMenuItem *item, - GParamSpec *pspec, - gpointer user_data) +ido_scale_menu_item_parent_set (GtkWidget *item, + GtkWidget *previous_parent) + { - if (g_strcmp0 (pspec->name, "parent")) - { - GtkWidget *parent = gtk_widget_get_parent (GTK_WIDGET (item)); + GtkWidget *parent; - if (parent) - { - g_signal_connect (parent, "hide", - G_CALLBACK (menu_hidden), - item); - } - } + if (previous_parent) + g_signal_handlers_disconnect_by_func (previous_parent, menu_hidden, item); + + parent = gtk_widget_get_parent (item); + if (parent) + g_signal_connect (parent, "hide", G_CALLBACK (menu_hidden), item); } static void |