From 0285d2680476e724c935372d87629ba6fb39ea3d Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Fri, 3 Sep 1999 03:57:14 +0000 Subject: [PATCH] Ref the RC style that is passed in. The lack of the ref before was a bug. Sun Sep 5 08:48:51 1999 Owen Taylor * gtk/gtkwidget.c (gtk_widget_modify_style): Ref the RC style that is passed in. The lack of the ref before was a bug. If people worked around this bug, this will introduce a slight memory leak in their code. The code should typically look like: rc_style = gtk_rc_style_new (); [...] gtk_widget_modify_style (widget, rc_style); gtk_rc_style_unref (rc_style); * gtk/gtkwidget.c (gtk_widget_modify_style): Reset the style if it was already set. * gtk/gtkwidget.c (gtk_widget_set_name): Only set the style if it was set before. --- gtk/gtkwidget.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index fc7ff38a0d..dd26a88136 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -3175,7 +3175,7 @@ gtk_widget_set_name (GtkWidget *widget, g_free (widget->name); widget->name = g_strdup (name); - if (!GTK_WIDGET_USER_STYLE (widget)) + if (GTK_WIDGET_RC_STYLE (widget)) gtk_widget_set_rc_style (widget); } @@ -3480,10 +3480,17 @@ gtk_widget_modify_style (GtkWidget *widget, old_style = gtk_object_get_data_by_id (GTK_OBJECT (widget), rc_style_key_id); if (style != old_style) - gtk_object_set_data_by_id_full (GTK_OBJECT (widget), - rc_style_key_id, - style, - (GtkDestroyNotify)gtk_rc_style_unref); + { + gtk_rc_style_ref (style); + + gtk_object_set_data_by_id_full (GTK_OBJECT (widget), + rc_style_key_id, + style, + (GtkDestroyNotify)gtk_rc_style_unref); + } + + if (GTK_WIDGET_RC_STYLE (widget)) + gtk_widget_set_rc_style (widget); } static void