aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2004-10-17 23:33:00 +0800
committerChristian Persch <chpe@src.gnome.org>2004-10-17 23:33:00 +0800
commitaff20a83bfb6d11baf553ad5a1364331ccee62bf (patch)
tree4545b84f63a11b50beae092e094db1d673a15715 /lib
parent611e5407571e19353a98292d953e90e63073ba61 (diff)
downloadgsoc2013-epiphany-aff20a83bfb6d11baf553ad5a1364331ccee62bf.tar
gsoc2013-epiphany-aff20a83bfb6d11baf553ad5a1364331ccee62bf.tar.gz
gsoc2013-epiphany-aff20a83bfb6d11baf553ad5a1364331ccee62bf.tar.bz2
gsoc2013-epiphany-aff20a83bfb6d11baf553ad5a1364331ccee62bf.tar.lz
gsoc2013-epiphany-aff20a83bfb6d11baf553ad5a1364331ccee62bf.tar.xz
gsoc2013-epiphany-aff20a83bfb6d11baf553ad5a1364331ccee62bf.tar.zst
gsoc2013-epiphany-aff20a83bfb6d11baf553ad5a1364331ccee62bf.zip
Fix EphyNode callback data destruction. Patch by Peter Harvey, fixes bug
2004-10-17 Christian Persch <chpe@cvs.gnome.org> * lib/ephy-node.c: (signal_object_weak_notify), (destroy_signal_data), (ephy_node_destroy), (ephy_node_new_with_id), (ephy_node_unref): Fix EphyNode callback data destruction. Patch by Peter Harvey, fixes bug #152718.
Diffstat (limited to 'lib')
-rw-r--r--lib/ephy-node.c81
1 files changed, 35 insertions, 46 deletions
diff --git a/lib/ephy-node.c b/lib/ephy-node.c
index ed5e23eb8..db9990147 100644
--- a/lib/ephy-node.c
+++ b/lib/ephy-node.c
@@ -169,33 +169,6 @@ ephy_node_emit_signal (EphyNode *node, EphyNodeSignalType type, ...)
va_end (data.valist);
}
-static void
-ephy_node_finalize (EphyNode *node)
-{
- guint i;
-
- g_hash_table_destroy (node->signals);
- node->signals = NULL;
-
- for (i = 0; i < node->properties->len; i++) {
- GValue *val;
-
- val = g_ptr_array_index (node->properties, i);
-
- if (val != NULL) {
- g_value_unset (val);
- g_free (val);
- }
- }
- g_ptr_array_free (node->properties, TRUE);
-
- g_hash_table_destroy (node->parents);
-
- g_ptr_array_free (node->children, TRUE);
-
- g_free (node);
-}
-
static inline void
real_remove_child (EphyNode *node,
EphyNode *child,
@@ -250,13 +223,12 @@ static void
signal_object_weak_notify (EphyNodeSignalData *signal_data,
GObject *where_the_object_was)
{
+ signal_data->data = NULL;
ephy_node_signal_disconnect (signal_data->node, signal_data->id);
}
static void
-unref_signal_objects (long id,
- EphyNodeSignalData *signal_data,
- EphyNode *node)
+destroy_signal_data (EphyNodeSignalData *signal_data)
{
if (signal_data->data)
{
@@ -264,20 +236,24 @@ unref_signal_objects (long id,
(GWeakNotify)signal_object_weak_notify,
signal_data);
}
+
+ g_free (signal_data);
}
static void
-ephy_node_dispose (EphyNode *node)
+ephy_node_destroy (EphyNode *node)
{
guint i;
ephy_node_emit_signal (node, EPHY_NODE_DESTROY);
- /* remove from DAG */
+ /* Remove from parents. */
g_hash_table_foreach (node->parents,
(GHFunc) remove_child,
node);
+ g_hash_table_destroy (node->parents);
+ /* Remove children. */
for (i = 0; i < node->children->len; i++) {
EphyNode *child;
@@ -285,12 +261,28 @@ ephy_node_dispose (EphyNode *node)
real_remove_child (node, child, FALSE, TRUE);
}
+ g_ptr_array_free (node->children, TRUE);
+
+ /* Remove signals. */
+ g_hash_table_destroy (node->signals);
- g_hash_table_foreach (node->signals,
- (GHFunc) unref_signal_objects,
- node);
-
+ /* Remove id. */
_ephy_node_db_remove_id (node->db, node->id);
+
+ /* Remove properties. */
+ for (i = 0; i < node->properties->len; i++) {
+ GValue *val;
+
+ val = g_ptr_array_index (node->properties, i);
+
+ if (val != NULL) {
+ g_value_unset (val);
+ g_free (val);
+ }
+ }
+ g_ptr_array_free (node->properties, TRUE);
+
+ g_free (node);
}
EphyNode *
@@ -328,15 +320,13 @@ ephy_node_new_with_id (EphyNodeDb *db, guint reserved_id)
node->children = g_ptr_array_new ();
- node->parents = g_hash_table_new_full (int_hash,
- int_equal,
- NULL,
- g_free);
+ node->parents = g_hash_table_new_full
+ (int_hash, int_equal, NULL, g_free);
+
+ node->signals = g_hash_table_new_full
+ (int_hash, int_equal, NULL,
+ (GDestroyNotify)destroy_signal_data);
- node->signals = g_hash_table_new_full (int_hash,
- int_equal,
- NULL,
- g_free);
node->signal_id = 0;
_ephy_node_db_add_id (db, reserved_id, node);
@@ -380,8 +370,7 @@ ephy_node_unref (EphyNode *node)
node->ref_count--;
if (node->ref_count <= 0) {
- ephy_node_dispose (node);
- ephy_node_finalize (node);
+ ephy_node_destroy (node);
}
}