Thu Jul 15 22:19:40 2004  Matthias Clasen  <maclas@gmx.de>

	Fix #60128, #58307, #144706:

	* gtk/gtkstyle.c (gtk_style_real_copy): Handle references
	to bg_pixmaps properly.
	(gtk_style_real_unrealize): Don't keep dangling references
	to the bg_pixmaps.
	(gtk_style_attach): Split the loop into two loops, first
	looking for a matching style, then for an empty one.
	(gtk_style_finalize):
	(gtk_style_duplicate): Add comments explaining the handling
	of style->styles.
This commit is contained in:
Matthias Clasen 2004-07-16 02:22:48 +00:00 committed by Matthias Clasen
parent f436df88d3
commit 2da944fb09
5 changed files with 100 additions and 26 deletions

View File

@ -1,3 +1,17 @@
Thu Jul 15 22:19:40 2004 Matthias Clasen <maclas@gmx.de>
Fix #60128, #58307, #144706:
* gtk/gtkstyle.c (gtk_style_real_copy): Handle references
to bg_pixmaps properly.
(gtk_style_real_unrealize): Don't keep dangling references
to the bg_pixmaps.
(gtk_style_attach): Split the loop into two loops, first
looking for a matching style, then for an empty one.
(gtk_style_finalize):
(gtk_style_duplicate): Add comments explaining the handling
of style->styles.
Thu Jul 15 20:31:28 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkspinbutton.c (start_spinning): Install the timeout

View File

@ -1,3 +1,17 @@
Thu Jul 15 22:19:40 2004 Matthias Clasen <maclas@gmx.de>
Fix #60128, #58307, #144706:
* gtk/gtkstyle.c (gtk_style_real_copy): Handle references
to bg_pixmaps properly.
(gtk_style_real_unrealize): Don't keep dangling references
to the bg_pixmaps.
(gtk_style_attach): Split the loop into two loops, first
looking for a matching style, then for an empty one.
(gtk_style_finalize):
(gtk_style_duplicate): Add comments explaining the handling
of style->styles.
Thu Jul 15 20:31:28 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkspinbutton.c (start_spinning): Install the timeout

View File

@ -1,3 +1,17 @@
Thu Jul 15 22:19:40 2004 Matthias Clasen <maclas@gmx.de>
Fix #60128, #58307, #144706:
* gtk/gtkstyle.c (gtk_style_real_copy): Handle references
to bg_pixmaps properly.
(gtk_style_real_unrealize): Don't keep dangling references
to the bg_pixmaps.
(gtk_style_attach): Split the loop into two loops, first
looking for a matching style, then for an empty one.
(gtk_style_finalize):
(gtk_style_duplicate): Add comments explaining the handling
of style->styles.
Thu Jul 15 20:31:28 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkspinbutton.c (start_spinning): Install the timeout

View File

@ -1,3 +1,17 @@
Thu Jul 15 22:19:40 2004 Matthias Clasen <maclas@gmx.de>
Fix #60128, #58307, #144706:
* gtk/gtkstyle.c (gtk_style_real_copy): Handle references
to bg_pixmaps properly.
(gtk_style_real_unrealize): Don't keep dangling references
to the bg_pixmaps.
(gtk_style_attach): Split the loop into two loops, first
looking for a matching style, then for an empty one.
(gtk_style_finalize):
(gtk_style_duplicate): Add comments explaining the handling
of style->styles.
Thu Jul 15 20:31:28 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkspinbutton.c (start_spinning): Install the timeout

View File

@ -721,6 +721,13 @@ gtk_style_finalize (GObject *object)
clear_property_cache (style);
/* All the styles in the list have the same
* style->styles pointer. If we delete the
* *first* style from the list, we need to update
* the style->styles pointers from all the styles.
* Otherwise we simply remove the node from
* the list.
*/
if (style->styles)
{
if (style->styles->data != style)
@ -788,6 +795,11 @@ gtk_style_duplicate (GtkStyle *style)
new_style = gtk_style_copy (style);
/* All the styles in the list have the same
* style->styles pointer. When we insert a new
* style, we append it to the list to avoid having
* to update the existing ones.
*/
style->styles = g_slist_append (style->styles, new_style);
new_style->styles = style->styles;
@ -825,22 +837,6 @@ gtk_style_new (void)
* involve the creation of a new style if the style has already
* been attached to a window with a different style and colormap.
**/
/*
* FIXME: The sequence -
* create a style => s1
* attach s1 to v1, c1 => s1
* attach s1 to v2, c2 => s2
* detach s1 from v1, c1
* attach s1 to v2, c2 => s3
* results in two separate, unlinked styles s2 and s3 which
* are identical and could be shared. To fix this, we would
* want to never remove a style from the list of linked
* styles as long as as it has a reference count. However, the
* disadvantage of doing it this way means that we would need two
* passes through the linked list when attaching (one to check for
* matching styles, one to look for empty unattached styles - but
* it will almost never be longer than 2 elements.
*/
GtkStyle*
gtk_style_attach (GtkStyle *style,
GdkWindow *window)
@ -862,17 +858,31 @@ gtk_style_attach (GtkStyle *style,
{
new_style = styles->data;
if (new_style->attach_count == 0)
{
gtk_style_realize (new_style, colormap);
break;
}
else if (new_style->colormap == colormap)
if (new_style->colormap == colormap)
break;
new_style = NULL;
styles = styles->next;
}
if (!new_style)
{
styles = style->styles;
while (styles)
{
new_style = styles->data;
if (new_style->attach_count == 0)
{
gtk_style_realize (new_style, colormap);
break;
}
new_style = NULL;
styles = styles->next;
}
}
if (!new_style)
{
@ -1672,8 +1682,12 @@ gtk_style_real_copy (GtkStyle *style,
style->bg[i] = src->bg[i];
style->text[i] = src->text[i];
style->base[i] = src->base[i];
if (style->bg_pixmap[i])
g_object_unref (style->bg_pixmap[i]),
style->bg_pixmap[i] = src->bg_pixmap[i];
if (style->bg_pixmap[i])
g_object_ref (style->bg_pixmap[i]);
}
if (style->private_font)
@ -1903,7 +1917,7 @@ gtk_style_real_realize (GtkStyle *style)
for (i = 0; i < 5; i++)
{
if (style->rc_style && style->rc_style->bg_pixmap_name[i])
style->bg_pixmap[i] = load_bg_image (style->colormap,
style->bg_pixmap[i] = load_bg_image (style->colormap,
&style->bg[i],
style->rc_style->bg_pixmap_name[i]);
@ -1978,7 +1992,11 @@ gtk_style_real_unrealize (GtkStyle *style)
gtk_gc_release (style->text_aa_gc[i]);
if (style->bg_pixmap[i] && style->bg_pixmap[i] != (GdkPixmap*) GDK_PARENT_RELATIVE)
g_object_unref (style->bg_pixmap[i]);
{
g_object_unref (style->bg_pixmap[i]);
style->bg_pixmap[i] = NULL;
}
}
gdk_colormap_free_colors (style->colormap, style->fg, 5);