Пример #1
0
void gf_svg_node_del(GF_Node *node)
{
	SVG_Element *p = (SVG_Element *)node;

	if (p->sgprivate->interact && p->sgprivate->interact->animations) {
		gf_smil_anim_delete_animations((GF_Node *)p);
	}
	if (p->sgprivate->tag==TAG_SVG_listener) {
		/*remove from target's listener list*/
		GF_DOMEventTarget *evt = node->sgprivate->UserPrivate;
		node->sgprivate->UserPrivate = NULL;
		if (evt) 
			gf_list_del_item(evt->evt_list, p);
#if 0
		if (evt && (gf_node_get_attribute_by_tag(p, TAG_XMLEV_ATT_event, 0, 0, &info) == GF_OK)) {
			u32 type = ((XMLEV_Event *)info.far_ptr)->type;
			gf_sg_unregister_event_type(p->sgprivate->scenegraph, gf_dom_event_get_category(type));
		}
#endif
	}
	/*if this is a handler with a UserPrivate, this is a handler with an implicit listener 
	(eg handler with ev:event=""). Destroy the associated listener*/
	if (p->sgprivate->tag==TAG_SVG_handler) {
		GF_Node *listener = p->sgprivate->UserPrivate;
		if (listener && (listener->sgprivate->tag==TAG_SVG_listener)) {
			gf_node_unregister(listener, NULL);
//			gf_svg_node_del(listener);
		}
	}
	/*remove this node from associated listeners*/
	if (node->sgprivate->interact && node->sgprivate->interact->dom_evt) {
		u32 i, count;
		count = gf_dom_listener_count(node);
		for (i=0; i<count; i++) {
			GF_Node *listener = gf_list_get(node->sgprivate->interact->dom_evt->evt_list, i);
			listener->sgprivate->UserPrivate = NULL;
		}
	}

	if (gf_svg_is_timing_tag(node->sgprivate->tag)) {
		SVGTimedAnimBaseElement *tap = (SVGTimedAnimBaseElement *)node;
		if (tap->animp) {
			gf_free(tap->animp);
			gf_smil_anim_remove_from_target((GF_Node *)tap, (GF_Node *)tap->xlinkp->href->target);
		}
		if (tap->timingp)		{
			gf_smil_timing_delete_runtime_info((GF_Node *)tap, tap->timingp->runtime);
			gf_free(tap->timingp);
		}	
		if (tap->xlinkp)	gf_free(tap->xlinkp);
	}

	gf_node_delete_attributes(node);
	gf_sg_parent_reset(node);
	gf_node_free(node);
}
Пример #2
0
void gf_svg_node_del(GF_Node *node)
{
	SVG_Element *p = (SVG_Element *)node;

	if (p->sgprivate->interact && p->sgprivate->interact->animations) {
		gf_smil_anim_delete_animations((GF_Node *)p);
	}
	if (p->sgprivate->tag==TAG_SVG_listener) {
		/*remove from target's listener list*/
		gf_dom_event_remove_listener_from_parent((GF_DOMEventTarget *)node->sgprivate->UserPrivate, (GF_Node *)p);
	}
	/*if this is a handler with a UserPrivate, this is a handler with an implicit listener
	(eg handler with ev:event=""). Destroy the associated listener*/
	if (p->sgprivate->tag==TAG_SVG_handler) {
		GF_Node *listener = p->sgprivate->UserPrivate;
		if (listener && (listener->sgprivate->tag==TAG_SVG_listener)) {
			GF_FieldInfo info;
			if (gf_node_get_attribute_by_tag(listener, TAG_XMLEV_ATT_handler, 0, 0, &info) == GF_OK) {
				XMLRI *iri = (XMLRI *)info.far_ptr;
				if (iri->target) {
					assert(iri->target==p);
					iri->target = NULL;
				}
			}
			gf_node_unregister(listener, NULL);
//			gf_svg_node_del(listener);
		}
	}
	/*remove this node from associated listeners*/
	if (node->sgprivate->interact && node->sgprivate->interact->dom_evt) {
		u32 i, count;
		count = gf_dom_listener_count(node);
		for (i=0; i<count; i++) {
			GF_Node *listener = (GF_Node *)gf_list_get(node->sgprivate->interact->dom_evt->listeners, i);
			listener->sgprivate->UserPrivate = NULL;
		}
	}

	if (gf_svg_is_timing_tag(node->sgprivate->tag)) {
		SVGTimedAnimBaseElement *tap = (SVGTimedAnimBaseElement *)node;
		if (tap->animp) {
			gf_free(tap->animp);
			gf_smil_anim_remove_from_target((GF_Node *)tap, (GF_Node *)tap->xlinkp->href->target);
		}
		if (tap->timingp)		{
			gf_smil_timing_delete_runtime_info((GF_Node *)tap, tap->timingp->runtime);
			gf_free(tap->timingp);
		}
		if (tap->xlinkp)	gf_free(tap->xlinkp);
	}

	gf_node_delete_attributes(node);
	gf_sg_parent_reset(node);
	gf_node_free(node);
}