[gnumeric] GnmColor: plug leaks.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] GnmColor: plug leaks.
- Date: Tue, 22 Apr 2014 19:17:38 +0000 (UTC)
commit ab6184dab61dce1cdc5dc1b95bfa5db817ab1800
Author: Morten Welinder <terra gnome org>
Date: Tue Apr 22 15:16:15 2014 -0400
GnmColor: plug leaks.
ChangeLog | 6 ++++++
NEWS | 1 +
src/sheet-style.c | 11 ++++++++---
src/style-color.c | 42 +++++++++++++++++++++++++++---------------
4 files changed, 42 insertions(+), 18 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 4ed7dff..cdd0407 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+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
diff --git a/NEWS b/NEWS
index 0829658..db35447 100644
--- a/NEWS
+++ b/NEWS
@@ -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
diff --git a/src/sheet-style.c b/src/sheet-style.c
index 15f9029..b97c260 100644
--- a/src/sheet-style.c
+++ b/src/sheet-style.c
@@ -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
diff --git a/src/style-color.c b/src/style-color.c
index 2701bb4..e9919f7 100644
--- a/src/style-color.c
+++ b/src/style-color.c
@@ -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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]