[anjuta] libanjuta, am-project: better memory management for the properties lists



commit 88f607162a1a7e3ed40161cf980b7367f88536ea
Author: Abderrahim Kitouni <a kitouni gmail com>
Date:   Wed Dec 21 16:28:05 2011 +0100

    libanjuta, am-project: better memory management for the properties lists
    
    properties is now owned fully by the node, while only the list
    properties_info (not its content) is owned by tho node.

 libanjuta/anjuta-project.c      |    6 ++++++
 plugins/am-project/amp-group.c  |    1 -
 plugins/am-project/amp-node.c   |    9 ++++++++-
 plugins/am-project/amp-source.c |    1 -
 plugins/am-project/amp-target.c |    1 -
 5 files changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/libanjuta/anjuta-project.c b/libanjuta/anjuta-project.c
index b1e985a..e9708a4 100644
--- a/libanjuta/anjuta-project.c
+++ b/libanjuta/anjuta-project.c
@@ -1152,6 +1152,12 @@ anjuta_project_node_finalize (GObject *object)
 
 	if (node->name != NULL) g_free (node->name);
 
+	g_list_free_full (node->properties, (GDestroyNotify) anjuta_project_property_free);
+	node->properties = NULL;
+
+	g_list_free (node->properties_info);
+	node->properties_info = NULL;
+
 	G_OBJECT_CLASS (anjuta_project_node_parent_class)->finalize (object);
 }
 
diff --git a/plugins/am-project/amp-group.c b/plugins/am-project/amp-group.c
index 55aeef5..3d0ec82 100644
--- a/plugins/am-project/amp-group.c
+++ b/plugins/am-project/amp-group.c
@@ -671,7 +671,6 @@ amp_group_node_finalize (GObject *object)
 	AmpGroupNode *node = AMP_GROUP_NODE (object);
 	gint i;
 
-	g_list_foreach (node->base.properties, (GFunc)amp_property_free, NULL);
 	if (node->tfile) anjuta_token_file_free (node->tfile);
 	if (node->makefile) g_object_unref (node->makefile);
 
diff --git a/plugins/am-project/amp-node.c b/plugins/am-project/amp-node.c
index 67b94ae..cf64fce 100644
--- a/plugins/am-project/amp-node.c
+++ b/plugins/am-project/amp-node.c
@@ -26,6 +26,8 @@
 
 #include "amp-node.h"
 
+#include "am-properties.h"
+
 #include "amp-root.h"
 #include "amp-module.h"
 #include "amp-package.h"
@@ -260,7 +262,12 @@ amp_node_finalize (GObject *object)
 {
 	AmpNode *node = AMP_NODE (object);
 
-	//g_list_foreach (node->parent.custom_properties, (GFunc)amp_property_free, NULL);
+	/* Subclasses set this directly and it should not be freed. */
+	node->parent.properties_info = NULL;
+
+	g_list_foreach (node->parent.properties, (GFunc)amp_property_free, NULL);
+	g_list_free (node->parent.properties);
+	node->parent.properties = NULL;
 
 	G_OBJECT_CLASS (amp_node_parent_class)->finalize (object);
 }
diff --git a/plugins/am-project/amp-source.c b/plugins/am-project/amp-source.c
index de3b55c..71fb1eb 100644
--- a/plugins/am-project/amp-source.c
+++ b/plugins/am-project/amp-source.c
@@ -158,7 +158,6 @@ amp_source_node_finalize (GObject *object)
 {
 	AmpSourceNode *node = AMP_SOURCE_NODE (object);
 
-	g_list_foreach (node->base.properties, (GFunc)amp_property_free, NULL);
 	G_OBJECT_CLASS (amp_source_node_parent_class)->finalize (object);
 }
 
diff --git a/plugins/am-project/amp-target.c b/plugins/am-project/amp-target.c
index 51987d2..3a092ac 100644
--- a/plugins/am-project/amp-target.c
+++ b/plugins/am-project/amp-target.c
@@ -515,7 +515,6 @@ amp_target_node_finalize (GObject *object)
 {
 	AmpTargetNode *node = AMP_TARGET_NODE (object);
 
-	g_list_foreach (node->base.properties, (GFunc)amp_property_free, NULL);
 	tagged_token_list_free (node->tokens);
 	node->tokens = NULL;
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]