Ref/unref the nodes at the toplevel rsvg-base

parent aec1ceac
......@@ -194,7 +194,7 @@ add_node_to_handle (RsvgHandle *ctx, RsvgNode *node)
g_assert (ctx != NULL);
g_assert (node != NULL);
g_ptr_array_add (ctx->priv->all_nodes, node);
g_ptr_array_add (ctx->priv->all_nodes, rsvg_node_ref (node));
}
static void
......@@ -423,12 +423,14 @@ rsvg_standard_element_start (RsvgHandle * ctx, const char *name, RsvgPropertyBag
if (ctx->priv->currentnode) {
rsvg_node_add_child (ctx->priv->currentnode, newnode);
} else if (rsvg_node_get_type (newnode) == RSVG_NODE_TYPE_SVG) {
ctx->priv->treebase = newnode;
ctx->priv->treebase = rsvg_node_ref (newnode);
}
ctx->priv->currentnode = rsvg_node_ref (newnode);
node_set_atts (newnode, ctx, creator, atts);
rsvg_node_unref (newnode);
}
}
......@@ -507,7 +509,7 @@ rsvg_start_extra (RsvgHandle * ctx,
* This isn't quite the correct behavior - any graphics
* element may contain a <extra> element.
*/
do_care = treebase != NULL && treebase == currentnode;
do_care = treebase != NULL && rsvg_node_is_same (treebase, currentnode);
handler->super.free = rsvg_extra_handler_free;
handler->super.characters = rsvg_extra_handler_characters;
......@@ -830,7 +832,11 @@ rsvg_end_element (void *data, const xmlChar * xmlname)
}
if (ctx->priv->currentnode && topmost_element_name_is (ctx, name)) {
ctx->priv->currentnode = rsvg_node_get_parent (ctx->priv->currentnode);
RsvgNode *parent;
parent = rsvg_node_get_parent (ctx->priv->currentnode);
ctx->priv->currentnode = rsvg_object_unref (ctx->priv->currentnode);
ctx->priv->currentnode = parent;
pop_element_name (ctx);
}
......
......@@ -42,7 +42,7 @@ rsvg_defs_new (RsvgHandle *handle)
{
RsvgDefs *result = g_new (RsvgDefs, 1);
result->hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
result->hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, rsvg_node_unref);
result->externs =
g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_object_unref);
result->ctx = handle; /* no need to take a ref here */
......@@ -130,7 +130,7 @@ rsvg_defs_register_node_by_id (RsvgDefs *defs, const char *id, RsvgNode *node)
if (g_hash_table_lookup (defs->hash, id))
return;
g_hash_table_insert (defs->hash, g_strdup (id), node);
g_hash_table_insert (defs->hash, g_strdup (id), rsvg_node_ref (node));
}
void
......
......@@ -134,6 +134,9 @@ rsvg_handle_dispose (GObject *instance)
g_hash_table_destroy (self->priv->css_props);
self->priv->treebase = rsvg_node_unref (self->priv->treebase);
self->priv->currentnode = rsvg_node_unref (self->priv->currentnode);
if (self->priv->user_data_destroy)
(*self->priv->user_data_destroy) (self->priv->user_data);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment