From 8e19b765433978fdec02a38597caac40345a7eb8 Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Tue, 28 Jan 2014 19:47:05 +0100 Subject: [PATCH] GtkStyleContext: don't use disconnect_by_func() disconnect_by_func() is slow, and this becomes particularly evident when disposing a number of widgets (and their associated style context) at once, such as when using a language binding which uses a GC. https://bugzilla.gnome.org/show_bug.cgi?id=723183 --- gtk/gtkstylecontext.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 18ef29a601..859a007c20 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -355,8 +355,8 @@ struct _GtkStyleContextPrivate { GdkScreen *screen; + guint cascade_changed_id; GtkStyleCascade *cascade; - GtkStyleContext *parent; GSList *children; GtkWidget *widget; @@ -684,21 +684,20 @@ gtk_style_context_set_cascade (GtkStyleContext *context, if (priv->cascade == cascade) return; + if (priv->cascade) + { + g_signal_handler_disconnect (priv->cascade, priv->cascade_changed_id); + priv->cascade_changed_id = 0; + g_object_unref (priv->cascade); + } + if (cascade) { g_object_ref (cascade); - g_signal_connect (cascade, - "-gtk-private-changed", - G_CALLBACK (gtk_style_context_cascade_changed), - context); - } - - if (priv->cascade) - { - g_signal_handlers_disconnect_by_func (priv->cascade, - gtk_style_context_cascade_changed, - context); - g_object_unref (priv->cascade); + priv->cascade_changed_id = g_signal_connect (cascade, + "-gtk-private-changed", + G_CALLBACK (gtk_style_context_cascade_changed), + context); } priv->cascade = cascade;