diff --git a/include/osg/ref_ptr b/include/osg/ref_ptr index 86bb83fac..948d2f0bb 100644 --- a/include/osg/ref_ptr +++ b/include/osg/ref_ptr @@ -18,6 +18,8 @@ namespace osg { +template class observer_ptr; + /** Smart pointer for handling referenced counted objects.*/ template class ref_ptr @@ -29,7 +31,7 @@ class ref_ptr ref_ptr(T* ptr) : _ptr(ptr) { if (_ptr) _ptr->ref(); } ref_ptr(const ref_ptr& rp) : _ptr(rp._ptr) { if (_ptr) _ptr->ref(); } template ref_ptr(const ref_ptr& rp) : _ptr(rp._ptr) { if (_ptr) _ptr->ref(); } - + ref_ptr(observer_ptr& optr) : _ptr(0) { optr.lock(*this); } ~ref_ptr() { if (_ptr) _ptr->unref(); _ptr = 0; } ref_ptr& operator = (const ref_ptr& rp) diff --git a/src/osgDB/DatabasePager.cpp b/src/osgDB/DatabasePager.cpp index 31d77d6ab..36fdfba26 100644 --- a/src/osgDB/DatabasePager.cpp +++ b/src/osgDB/DatabasePager.cpp @@ -1612,8 +1612,8 @@ void DatabasePager::removeExpiredSubgraphs(const osg::FrameStamp& frameStamp) itr != _activePagedLODList.end(); ) { - osg::ref_ptr plod; - if (itr->lock(plod)) + osg::ref_ptr plod(*itr); + if (plod.valid()) { int delta = frameStamp.getFrameNumber() - plod->getFrameNumberOfLastTraversal(); if (delta>1) @@ -1643,8 +1643,8 @@ void DatabasePager::removeExpiredSubgraphs(const osg::FrameStamp& frameStamp) itr != _inactivePagedLODList.end(); ) { - osg::ref_ptr plod; - if (itr->lock(plod)) + osg::ref_ptr plod(*itr); + if (plod.valid()) { int delta = frameStamp.getFrameNumber() - plod->getFrameNumberOfLastTraversal(); if (delta>1) @@ -1702,8 +1702,8 @@ void DatabasePager::removeExpiredSubgraphs(const osg::FrameStamp& frameStamp) itr!=_inactivePagedLODList.end() && countPagedLODsVisitor._numPagedLODs plod; - if (itr->lock(plod) && countPagedLODsVisitor._pagedLODs.count(plod.get())==0) + osg::ref_ptr plod(*itr); + if (plod.valid() && countPagedLODsVisitor._pagedLODs.count(plod.get())==0) { countPagedLODsVisitor.removeExpiredChildrenAndCountPagedLODs(plod.get(), expiryTime, expiryFrame, childrenRemoved); @@ -1721,8 +1721,8 @@ void DatabasePager::removeExpiredSubgraphs(const osg::FrameStamp& frameStamp) itr!=_activePagedLODList.end() && countPagedLODsVisitor._numPagedLODs plod; - if (itr->lock(plod) && countPagedLODsVisitor._pagedLODs.count(plod.get())==0) + osg::ref_ptr plod(*itr); + if (plod.valid() && countPagedLODsVisitor._pagedLODs.count(plod.get())==0) { countPagedLODsVisitor.removeExpiredChildrenAndCountPagedLODs(plod.get(), expiryTime, expiryFrame, childrenRemoved);