Commit 5d7721cd authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[FIX #425 #426] - fixing memory leak as sometimes, the operation queue keeps...

[FIX #425 #426] - fixing memory leak as sometimes, the operation queue keeps elements while destructing the node. This is now fixed.
parent 39af9481
......@@ -55,7 +55,7 @@ WGEGroupNode::~WGEGroupNode()
void WGEGroupNode::insert( osg::ref_ptr< osg::Node > node )
{
boost::unique_lock<boost::shared_mutex> lock = boost::unique_lock<boost::shared_mutex>( m_childOperationQueueLock );
m_childOperationQueue.push( new ChildOperation( INSERT, node ) );
m_childOperationQueue.push( boost::shared_ptr< ChildOperation >( new ChildOperation( INSERT, node ) ) );
m_childOperationQueueDirty = true;
lock.unlock();
}
......@@ -63,7 +63,7 @@ void WGEGroupNode::insert( osg::ref_ptr< osg::Node > node )
void WGEGroupNode::remove( osg::ref_ptr< osg::Node > node )
{
boost::unique_lock<boost::shared_mutex> lock = boost::unique_lock<boost::shared_mutex>( m_childOperationQueueLock );
m_childOperationQueue.push( new ChildOperation( REMOVE, node ) );
m_childOperationQueue.push( boost::shared_ptr< ChildOperation >( new ChildOperation( REMOVE, node ) ) );
m_childOperationQueueDirty = true;
lock.unlock();
}
......@@ -71,7 +71,7 @@ void WGEGroupNode::remove( osg::ref_ptr< osg::Node > node )
void WGEGroupNode::remove_if( boost::shared_ptr< WGEGroupNode::NodePredicate > predicate )
{
boost::unique_lock<boost::shared_mutex> lock = boost::unique_lock<boost::shared_mutex>( m_childOperationQueueLock );
m_childOperationQueue.push( new ChildOperation( REMOVE_IF, predicate ) );
m_childOperationQueue.push( boost::shared_ptr< ChildOperation >( new ChildOperation( REMOVE_IF, predicate ) ) );
m_childOperationQueueDirty = true;
lock.unlock();
}
......@@ -79,7 +79,8 @@ void WGEGroupNode::remove_if( boost::shared_ptr< WGEGroupNode::NodePredicate > p
void WGEGroupNode::clear()
{
boost::unique_lock<boost::shared_mutex> lock = boost::unique_lock<boost::shared_mutex>( m_childOperationQueueLock );
m_childOperationQueue.push( new ChildOperation( CLEAR, osg::ref_ptr< osg::Node >() ) ); // this encodes the remove all feature
m_childOperationQueue.push( boost::shared_ptr< ChildOperation >( new ChildOperation( CLEAR, osg::ref_ptr< osg::Node >() ) ) );
// this encodes the remove all feature
m_childOperationQueueDirty = true;
lock.unlock();
}
......@@ -135,9 +136,7 @@ void WGEGroupNode::SafeUpdaterCallback::operator()( osg::Node* node, osg::NodeVi
}
// pop item
ChildOperation* c = rootNode->m_childOperationQueue.front();
rootNode->m_childOperationQueue.pop();
delete c;
}
rootNode->dirtyBound();
......
......@@ -172,7 +172,7 @@ protected:
* Queue of childs that need to be added/removed during the next update cycle. It is a pair per operation, where the bool is denoting removal
* or insertion.
*/
std::queue< ChildOperation* > m_childOperationQueue;
std::queue< boost::shared_ptr< ChildOperation > > m_childOperationQueue;
/**
* Lock used for inserting and removing childs into the child insertion/removal queue.
......
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