Esempio n. 1
0
void SG_DeleteCommand(SGCommand *com)
{
	u32 i;
	if (!com) return;

	while (ChainGetCount(com->command_fields)) {
		CommandFieldInfo *inf = ChainGetEntry(com->command_fields, 0);
		ChainDeleteEntry(com->command_fields, 0);

		switch (inf->fieldType) {
		case FT_SFNode:
			if (inf->field_ptr && *(SFNode **) inf->field_ptr) Node_Unregister(*(SFNode **) inf->field_ptr, com->node);
			break;
		case FT_MFNode:
			Node_UnregisterChildren(com->node, *(Chain**) inf->field_ptr);
			DeleteChain(*(Chain**) inf->field_ptr);
			break;
		default:
			VRML_DeleteFieldPointer(inf->field_ptr, inf->fieldType);
			break;
		}
		free(inf);
	}
	DeleteChain(com->command_fields);

	for (i=0; i<ChainGetCount(com->new_proto_list); i++) {
		LPPROTO proto = ChainGetEntry(com->new_proto_list, i);
		SG_DeleteProto(proto);
	}
	DeleteChain(com->new_proto_list);

	if (com->node) {
		if (!com->in_scene) Node_Unregister(com->node, NULL);
		else SG_CheckNodeUnregister(com);
	}

	if (com->del_proto_list) free(com->del_proto_list);
	if (com->def_name) free(com->def_name);
	if (com->scripts_to_load) DeleteChain(com->scripts_to_load);
	free(com);
}
Esempio n. 2
0
GF_EXPORT
void gf_sg_command_del(GF_Command *com)
{
	u32 i;
	GF_Proto *proto;
	if (!com) return;

	if (com->tag < GF_SG_LAST_BIFS_COMMAND) {
		while (gf_list_count(com->command_fields)) {
			GF_CommandField *inf = (GF_CommandField *)gf_list_get(com->command_fields, 0);
			gf_list_rem(com->command_fields, 0);

			switch (inf->fieldType) {
			case GF_SG_VRML_SFNODE:
				if (inf->new_node) gf_node_unregister(inf->new_node, com->node);
				break;
			case GF_SG_VRML_MFNODE:
				if (inf->field_ptr) {
					GF_ChildNodeItem *cur, *child;
					child = inf->node_list;
					while (child) {
						cur = child;
						gf_node_unregister(child->node, com->node);
						child = child->next;
						free(cur);
					}
				}
				break;
			default:
				if (inf->field_ptr) gf_sg_vrml_field_pointer_del(inf->field_ptr, inf->fieldType);
				break;
			}
			free(inf);
		}
	} else {
#ifndef GPAC_DISABLE_SVG
		while (gf_list_count(com->command_fields)) {
			GF_CommandField *inf = (GF_CommandField *)gf_list_get(com->command_fields, 0);
			gf_list_rem(com->command_fields, 0);

			if (inf->new_node) gf_node_unregister(inf->new_node, com->node);
			else if (inf->node_list) {
				gf_node_unregister_children(com->node, inf->node_list);
			} else if (inf->field_ptr) {
				gf_svg_delete_attribute_value(inf->fieldType, inf->field_ptr, com->in_scene);
			}
			free(inf);
		}
#endif
	}
	gf_list_del(com->command_fields);

	i=0;
	while ((proto = (GF_Proto*)gf_list_enum(com->new_proto_list, &i))) {
		gf_sg_proto_del(proto);
	}
	gf_list_del(com->new_proto_list);

	if (com->node) {
		if (!com->in_scene) gf_node_unregister(com->node, NULL);
		else SG_CheckNodeUnregister(com);
	}

	if (com->del_proto_list) free(com->del_proto_list);
	if (com->def_name) free(com->def_name);
	if (com->scripts_to_load) gf_list_del(com->scripts_to_load);
	free(com);
}