Commit ab6184da authored by Morten Welinder's avatar Morten Welinder

GnmColor: plug leaks.

parent 04bec55f
2014-04-22 Morten Welinder <terra@gnome.org>
* src/sheet-style.c (sheet_style_init_size): Plug leak.
* src/style-color.c (gnm_color_shutdown): Free the auto colours.
2014-04-21 Morten Welinder <terra@gnome.org>
* src/gnumeric.css (GnmNotebook): Set padding for top and bottom
......
......@@ -11,6 +11,7 @@ Morten:
* Attempt a fix for tabs appearance with gtk+ 3.12. [#728465]
* Make it possible to have all callables as python functions. [#728611]
* Improve format roundtrip through ODF.
* Plug leaks.
--------------------------------------------------------------------------
Gnumeric 1.12.14
......
......@@ -669,10 +669,15 @@ sheet_style_init_size (Sheet *sheet, int cols, int rows)
sheet->style_data = g_new (GnmSheetStyleData, 1);
sheet->style_data->style_hash = sh_create ();
{
GnmColor *ap = style_color_auto_pattern ();
#warning "FIXME: Allocating a GnmColor here is dubious."
sheet->style_data->auto_pattern_color = g_new (GnmColor, 1);
*sheet->style_data->auto_pattern_color = *style_color_auto_pattern ();
sheet->style_data->auto_pattern_color->ref_count = 1;
sheet->style_data->auto_pattern_color = g_new (GnmColor, 1);
*sheet->style_data->auto_pattern_color = *ap;
sheet->style_data->auto_pattern_color->ref_count = 1;
style_color_unref (ap);
}
default_style = gnm_style_new_default ();
#if 0
......
......@@ -16,6 +16,9 @@ static GHashTable *style_color_hash;
static GnmColor *sc_black;
static GnmColor *sc_white;
static GnmColor *sc_grid;
static GnmColor *sc_auto_back;
static GnmColor *sc_auto_font;
static GnmColor *sc_auto_pattern;
GnmColor *
gnm_color_new_name (char const *name)
......@@ -134,11 +137,9 @@ style_color_grid (void)
GnmColor *
style_color_auto_font (void)
{
static GnmColor *color = NULL;
if (!color)
color = gnm_color_new_uninterned (GO_COLOR_BLACK, TRUE);
return style_color_ref (color);
if (!sc_auto_font)
sc_auto_font = gnm_color_new_uninterned (GO_COLOR_BLACK, TRUE);
return style_color_ref (sc_auto_font);
}
/**
......@@ -149,11 +150,9 @@ style_color_auto_font (void)
GnmColor *
style_color_auto_back (void)
{
static GnmColor *color = NULL;
if (!color)
color = gnm_color_new_uninterned (GO_COLOR_WHITE, TRUE);
return style_color_ref (color);
if (!sc_auto_back)
sc_auto_back = gnm_color_new_uninterned (GO_COLOR_WHITE, TRUE);
return style_color_ref (sc_auto_back);
}
/**
......@@ -164,11 +163,9 @@ style_color_auto_back (void)
GnmColor *
style_color_auto_pattern (void)
{
static GnmColor *color = NULL;
if (!color)
color = gnm_color_new_uninterned (GO_COLOR_BLACK, TRUE);
return style_color_ref (color);
if (!sc_auto_pattern)
sc_auto_pattern = gnm_color_new_uninterned (GO_COLOR_BLACK, TRUE);
return style_color_ref (sc_auto_pattern);
}
GnmColor *
......@@ -257,6 +254,21 @@ gnm_color_shutdown (void)
sc_grid = NULL;
}
if (sc_auto_back) {
style_color_unref (sc_auto_back);
sc_auto_back = NULL;
}
if (sc_auto_font) {
style_color_unref (sc_auto_font);
sc_auto_font = NULL;
}
if (sc_auto_pattern) {
style_color_unref (sc_auto_pattern);
sc_auto_pattern = NULL;
}
g_hash_table_foreach (style_color_hash, cb_color_leak, NULL);
g_hash_table_destroy (style_color_hash);
style_color_hash = NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment