[anjuta/newproject] Ref and unref GObject correctly using floating reference
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta/newproject] Ref and unref GObject correctly using floating reference
- Date: Wed, 22 Sep 2010 20:36:49 +0000 (UTC)
commit fb49910e9f68b830b3c7f0861cef43e982c8a420
Author: Sébastien Granjoux <seb sfo free fr>
Date: Wed Sep 22 22:34:20 2010 +0200
Ref and unref GObject correctly using floating reference
libanjuta/anjuta-project.c | 10 ++++++++--
libanjuta/anjuta-project.h | 8 ++++----
2 files changed, 12 insertions(+), 6 deletions(-)
---
diff --git a/libanjuta/anjuta-project.c b/libanjuta/anjuta-project.c
index 4789700..2496a9c 100644
--- a/libanjuta/anjuta-project.c
+++ b/libanjuta/anjuta-project.c
@@ -438,6 +438,8 @@ anjuta_project_node_insert_before (AnjutaProjectNode *parent, AnjutaProjectNode
if (sibling)
g_return_val_if_fail (sibling->parent == parent, node);*/
+ g_object_ref_sink (node);
+
node->parent = parent;
if (sibling)
{
@@ -485,6 +487,8 @@ anjuta_project_node_insert_after (AnjutaProjectNode *parent, AnjutaProjectNode *
if (sibling)
g_return_val_if_fail (sibling->parent == parent, node);*/
+ g_object_ref_sink (node);
+
node->parent = parent;
if (sibling)
{
@@ -513,7 +517,7 @@ AnjutaProjectNode *
anjuta_project_node_remove (AnjutaProjectNode *node)
{
g_return_val_if_fail (node != NULL, NULL);
-
+
if (node->prev)
node->prev->next = node->next;
else if (node->parent)
@@ -525,6 +529,8 @@ anjuta_project_node_remove (AnjutaProjectNode *node)
node->next = NULL;
}
node->prev = NULL;
+
+ g_object_force_floating (node);
return node;
}
@@ -1033,7 +1039,7 @@ enum {
static unsigned int anjuta_project_node_signals[LAST_SIGNAL] = { 0 };
-G_DEFINE_TYPE (AnjutaProjectNode, anjuta_project_node, G_TYPE_OBJECT);
+G_DEFINE_TYPE (AnjutaProjectNode, anjuta_project_node, G_TYPE_INITIALLY_UNOWNED);
static void
anjuta_project_node_init (AnjutaProjectNode *node)
diff --git a/libanjuta/anjuta-project.h b/libanjuta/anjuta-project.h
index de3de56..d5bf7ff 100644
--- a/libanjuta/anjuta-project.h
+++ b/libanjuta/anjuta-project.h
@@ -149,7 +149,7 @@ typedef void (*AnjutaProjectNodeForeachFunc) (AnjutaProjectNode *node, gpointer
*/
struct _AnjutaProjectNode
{
- GObject object;
+ GInitiallyUnowned parent_instance;
AnjutaProjectNode *next;
AnjutaProjectNode *prev;
@@ -166,7 +166,7 @@ struct _AnjutaProjectNode
struct _AnjutaProjectNodeClass
{
- GObjectClass parent_class;
+ GInitiallyUnownedClass parent_class;
void (*updated) (GError *error);
void (*loaded) (GError *error);
@@ -273,14 +273,14 @@ typedef struct _AnjutaProjectGObjectNode AnjutaProjectGObjectNode;
struct _AnjutaProjectGObjectNodeClass
{
GObjectClass parent_class;
-
+
void (*updated) (GError *error);
void (*loaded) (GError *error);
};
struct _AnjutaProjectGObjectNode
{
- GObject parent_instance;
+ GObject object;
GNode *next;
GNode *prev;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]