Added mutex locking add addParents/removeParents in Drawable, Node and StateSet.

This commit is contained in:
Robert Osfield
2007-08-31 20:14:36 +00:00
parent 1bc6d0bae4
commit 86e998f64c
4 changed files with 70 additions and 10 deletions

View File

@@ -78,7 +78,8 @@ bool osg::isTextureMode(StateAttribute::GLMode mode)
return getTextureGLModeSet().isTextureMode(mode);
}
StateSet::StateSet()
StateSet::StateSet():
Object(true)
{
_renderingHint = DEFAULT_BIN;
@@ -247,14 +248,32 @@ void StateSet::computeDataVariance()
void StateSet::addParent(osg::Object* object)
{
// osg::notify(osg::INFO)<<"Adding parent"<<std::endl;
if (getRefMutex())
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(*getRefMutex());
_parents.push_back(object);
_parents.push_back(object);
}
else
{
_parents.push_back(object);
}
}
void StateSet::removeParent(osg::Object* object)
{
ParentList::iterator pitr = std::find(_parents.begin(),_parents.end(),object);
if (pitr!=_parents.end()) _parents.erase(pitr);
if (getRefMutex())
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(*getRefMutex());
ParentList::iterator pitr = std::find(_parents.begin(),_parents.end(),object);
if (pitr!=_parents.end()) _parents.erase(pitr);
}
else
{
ParentList::iterator pitr = std::find(_parents.begin(),_parents.end(),object);
if (pitr!=_parents.end()) _parents.erase(pitr);
}
}
int StateSet::compare(const StateSet& rhs,bool compareAttributeContents) const