[gnome-builder] tree: use weak pointer for tree
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] tree: use weak pointer for tree
- Date: Sat, 20 Jun 2015 09:44:37 +0000 (UTC)
commit ae14732c9abdd7365bbb6b866e362a118eaa19b7
Author: Christian Hergert <christian hergert me>
Date: Sun Jun 14 20:09:36 2015 -0700
tree: use weak pointer for tree
src/tree/gb-tree-node.c | 22 +++++++++++++++++-----
1 files changed, 17 insertions(+), 5 deletions(-)
---
diff --git a/src/tree/gb-tree-node.c b/src/tree/gb-tree-node.c
index dd9ec3f..1148c2e 100644
--- a/src/tree/gb-tree-node.c
+++ b/src/tree/gb-tree-node.c
@@ -100,11 +100,23 @@ _gb_tree_node_set_tree (GbTreeNode *node,
GbTree *tree)
{
g_return_if_fail (GB_IS_TREE_NODE (node));
- g_return_if_fail (GB_IS_TREE (tree));
- g_return_if_fail ((node->tree == NULL) ||
- (node->tree == tree));
+ g_return_if_fail (!tree || GB_IS_TREE (tree));
- node->tree = tree;
+ if (node->tree != tree)
+ {
+ if (node->tree != NULL)
+ {
+ g_object_remove_weak_pointer (G_OBJECT (node->tree), (gpointer *)&node->tree);
+ node->tree = NULL;
+ }
+
+ if (tree != NULL)
+ {
+ node->tree = tree;
+ g_object_add_weak_pointer (G_OBJECT (node->tree), (gpointer *)&node->tree);
+ }
+ }
+}
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]