[goffice] GOColorGroup: leak fix.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] GOColorGroup: leak fix.
- Date: Thu, 21 Mar 2013 02:34:58 +0000 (UTC)
commit 1fb0847acf45a3fdaa12cb647abc5f7a29a6c30f
Author: Morten Welinder <terra gnome org>
Date: Wed Mar 20 22:30:38 2013 -0400
GOColorGroup: leak fix.
ChangeLog | 3 +++
goffice/gtk/go-color-group.c | 18 ++++++++++--------
2 files changed, 13 insertions(+), 8 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 308ba9f..6edb46a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2013-03-20 Morten Welinder <terra gnome org>
+ * goffice/gtk/go-color-group.c (go_color_group_finalize): Don't
+ leak the hash.
+
* goffice/gtk/go-combo-color.c (go_combo_color_class_init): Fix
type of first argument of color_changed signal. Fixes #696022.
diff --git a/goffice/gtk/go-color-group.c b/goffice/gtk/go-color-group.c
index 466e791..db6636e 100644
--- a/goffice/gtk/go-color-group.c
+++ b/goffice/gtk/go-color-group.c
@@ -55,11 +55,15 @@ go_color_group_finalize (GObject *obj)
/* make this name available */
if (cg->name) {
g_hash_table_remove (go_color_groups, cg);
+ if (g_hash_table_size (go_color_groups) == 0) {
+ g_hash_table_destroy (go_color_groups);
+ go_color_groups = NULL;
+ }
g_free (cg->name);
cg->name = NULL;
}
- (go_color_group_parent_class->finalize) (obj);
+ go_color_group_parent_class->finalize (obj);
}
static void
@@ -172,17 +176,15 @@ go_color_group_fetch (char const *name, gpointer context)
} else {
new_name = g_strdup (name);
cg = go_color_group_find (new_name, context);
- if (cg != NULL) {
- g_free (new_name);
- g_object_ref (cg);
- return cg;
- }
+ if (cg != NULL) {
+ g_free (new_name);
+ g_object_ref (cg);
+ return cg;
+ }
}
cg = g_object_new (go_color_group_get_type (), NULL);
- g_return_val_if_fail(cg != NULL, NULL);
-
cg->name = new_name;
cg->context = context;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]