diff --git a/plugins/3d/vrml/v1/vrml1_node.cpp b/plugins/3d/vrml/v1/vrml1_node.cpp index c9f03efc89..b22c54b297 100644 --- a/plugins/3d/vrml/v1/vrml1_node.cpp +++ b/plugins/3d/vrml/v1/vrml1_node.cpp @@ -460,6 +460,7 @@ bool WRL1NODE::AddRefNode( WRL1NODE* aNode ) // the same level; for example a Coordinate3 node can be recalled // at any time to set the current coordinate set. m_Refs.push_back( aNode ); + aNode->addNodeRef( this ); addItem( aNode ); return true; diff --git a/plugins/3d/vrml/v2/vrml2_node.cpp b/plugins/3d/vrml/v2/vrml2_node.cpp index c697f8f863..0d38428c74 100644 --- a/plugins/3d/vrml/v2/vrml2_node.cpp +++ b/plugins/3d/vrml/v2/vrml2_node.cpp @@ -140,9 +140,18 @@ WRL2NODE::~WRL2NODE() ++sBP; } + std::list< WRL2NODE* >::iterator sC = m_Refs.begin(); + std::list< WRL2NODE* >::iterator eC = m_Refs.end(); + + while( sC != eC ) + { + (*sC)->delNodeRef( this ); + ++sC; + } + m_Refs.clear(); - std::list< WRL2NODE* >::iterator sC = m_Children.begin(); - std::list< WRL2NODE* >::iterator eC = m_Children.end(); + sC = m_Children.begin(); + eC = m_Children.end(); while( sC != eC ) { @@ -416,6 +425,7 @@ bool WRL2NODE::AddRefNode( WRL2NODE* aNode ) } m_Refs.push_back( aNode ); + aNode->addNodeRef( this ); return true; } diff --git a/plugins/3d/vrml/v2/vrml2_switch.cpp b/plugins/3d/vrml/v2/vrml2_switch.cpp index 9be5127334..c49039c82c 100644 --- a/plugins/3d/vrml/v2/vrml2_switch.cpp +++ b/plugins/3d/vrml/v2/vrml2_switch.cpp @@ -195,19 +195,24 @@ bool WRL2SWITCH::AddRefNode( WRL2NODE* aNode ) return false; } - if( !WRL2NODE::AddRefNode( aNode ) ) - return false; - // take possession if the node is dangling WRL2_SHAPE - if( WRL2_SHAPE == aNode->GetNodeType() && aNode->isDangling() ) { WRL2NODE* np = aNode->GetParent(); if( NULL != np ) aNode->SetParent( this ); + + if( !WRL2NODE::AddChildNode( aNode ) ) + { + aNode->SetParent( NULL ); + return false; + } } + if( !WRL2NODE::AddRefNode( aNode ) ) + return false; + return true; } diff --git a/plugins/3d/vrml/v2/vrml2_transform.cpp b/plugins/3d/vrml/v2/vrml2_transform.cpp index 6a91796b3d..c579667d47 100644 --- a/plugins/3d/vrml/v2/vrml2_transform.cpp +++ b/plugins/3d/vrml/v2/vrml2_transform.cpp @@ -293,9 +293,6 @@ bool WRL2TRANSFORM::AddRefNode( WRL2NODE* aNode ) return false; } - if( !WRL2NODE::AddRefNode( aNode ) ) - return false; - // take possession if the node is dangling WRL2_SHAPE if( WRL2_SHAPE == aNode->GetNodeType() && aNode->isDangling() ) @@ -304,8 +301,18 @@ bool WRL2TRANSFORM::AddRefNode( WRL2NODE* aNode ) if( NULL != np ) aNode->SetParent( this ); + + + if( !WRL2NODE::AddChildNode( aNode ) ) + { + aNode->SetParent( NULL ); + return false; + } } + if( !WRL2NODE::AddRefNode( aNode ) ) + return false; + return true; } diff --git a/plugins/3d/vrml/x3d/x3d_ifaceset.cpp b/plugins/3d/vrml/x3d/x3d_ifaceset.cpp index d059f212bd..d8544d7258 100644 --- a/plugins/3d/vrml/x3d/x3d_ifaceset.cpp +++ b/plugins/3d/vrml/x3d/x3d_ifaceset.cpp @@ -228,6 +228,7 @@ bool X3DIFACESET::AddRefNode( X3DNODE* aNode ) return false; m_Refs.push_back( aNode ); + aNode->addNodeRef( this ); coord = aNode; return true; } diff --git a/plugins/3d/vrml/x3d/x3d_shape.cpp b/plugins/3d/vrml/x3d/x3d_shape.cpp index 73ed9090d2..6aa9ffa3df 100644 --- a/plugins/3d/vrml/x3d/x3d_shape.cpp +++ b/plugins/3d/vrml/x3d/x3d_shape.cpp @@ -219,6 +219,7 @@ bool X3DSHAPE::AddRefNode( X3DNODE* aNode ) if( NULL == appearance ) { m_Refs.push_back( aNode ); + aNode->addNodeRef( this ); appearance = aNode; } else @@ -229,6 +230,7 @@ bool X3DSHAPE::AddRefNode( X3DNODE* aNode ) if( NULL == geometry ) { m_Refs.push_back( aNode ); + aNode->addNodeRef( this ); geometry = aNode; } else diff --git a/plugins/3d/vrml/x3d/x3d_transform.cpp b/plugins/3d/vrml/x3d/x3d_transform.cpp index 74fdc649ec..ed95605be3 100644 --- a/plugins/3d/vrml/x3d/x3d_transform.cpp +++ b/plugins/3d/vrml/x3d/x3d_transform.cpp @@ -247,6 +247,7 @@ bool X3DTRANSFORM::AddRefNode( X3DNODE* aNode ) } m_Refs.push_back( aNode ); + aNode->addNodeRef( this ); return true; }