{
GF_Err e;
u32 NodeID, ind, field_ind, NumBits;
- GF_Node *node, *prev_node;
+ GF_Node *node;
GF_ChildNodeItem *prev_child;
GF_FieldInfo field;
e = gf_node_get_field(node, field_ind, &field);
if (e) return e;
- prev_node = NULL;
prev_child = NULL;
- /*store prev SF node*/
- if (field.fieldType == GF_SG_VRML_SFNODE) {
- prev_node = *((GF_Node **) field.far_ptr);
- }
/*store prev MFNode content*/
- else if (field.fieldType == GF_SG_VRML_MFNODE) {
+ if (field.fieldType == GF_SG_VRML_MFNODE) {
prev_child = * ((GF_ChildNodeItem **) field.far_ptr);
* ((GF_ChildNodeItem **) field.far_ptr) = NULL;
}
e = gf_bifs_dec_field(codec, bs, node, &field, GF_FALSE);
codec->is_com_dec = GF_FALSE;
/*remove prev nodes*/
- if (field.fieldType == GF_SG_VRML_SFNODE) {
- if (prev_node) e = gf_node_unregister(prev_node, node);
- } else if (field.fieldType == GF_SG_VRML_MFNODE) {
+ if (field.fieldType == GF_SG_VRML_MFNODE) {
gf_node_unregister_children(node, prev_child);
}
if (!e) gf_bifs_check_field_change(node, &field);
}
break;
case GF_SG_VRML_SFNODE:
+ //if not memory dec mode, unregister previous node
+ //otherwise the field points to the memory command internal field
+ if (!is_mem_com) {
+ if ( *((GF_Node **) field->far_ptr) != NULL) {
+ gf_node_unregister(*((GF_Node **) field->far_ptr), node);
+ *((GF_Node **) field->far_ptr) = NULL;
+ }
+ }
//for nodes the field ptr is a ptr to the field, which is a node ptr ;)
new_node = gf_bifs_dec_node(codec, bs, field->NDTtype);
if (new_node) {
return NULL;
}
- /*VRML: "The transformation hierarchy shall be a directed acyclic graph; results are undefined if a node
- in the transformation hierarchy is its own ancestor"
- that's good, because the scene graph can't handle cyclic graphs (destroy will never be called).
- We therefore only register the node once parsed*/
- if (nodeID) {
- if (strlen(name)) {
- gf_node_set_id(new_node, nodeID, name);
- } else {
- gf_node_set_id(new_node, nodeID, NULL);
- }
- }
-
-
/*update default time fields except in proto parsing*/
if (!codec->pCurrentProto) UpdateTimeNode(codec, new_node);
/*nodes are only init outside protos, nodes internal to protos are never intialized */
return NULL;
}
+ /*VRML: "The transformation hierarchy shall be a directed acyclic graph; results are undefined if a node
+ in the transformation hierarchy is its own ancestor"
+ that's good, because the scene graph can't handle cyclic graphs (destroy will never be called).
+ We therefore only register the node once parsed*/
+ if (nodeID) {
+ if (strlen(name)) {
+ gf_node_set_id(new_node, nodeID, name);
+ } else {
+ gf_node_set_id(new_node, nodeID, NULL);
+ }
+ }
+
if (!skip_init)
gf_node_init(new_node);