summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>1999-09-03 03:57:14 +0000
committerOwen Taylor <otaylor@src.gnome.org>1999-09-03 03:57:14 +0000
commit0285d2680476e724c935372d87629ba6fb39ea3d (patch)
tree53e16d9d34ba5764ccb9cd302af49fcf6895d284
parent189706f619c3ec38c001573b3d6890e3a46d2501 (diff)
downloadgdk-pixbuf-0285d2680476e724c935372d87629ba6fb39ea3d.tar.gz
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 <otaylor@redhat.com> * 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.
-rw-r--r--gtk/gtkwidget.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index fc7ff38a0..dd26a8813 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