From Tim Moore, "This is a patch that allows a ref_ptr to be constructed using an observer_ptr argument, which is locked. This is shorthand for declaring the ref_ptr and then passing it to observer_ptr::lock().
"
This commit is contained in:
parent
0c6739b6dc
commit
054d5606fb
@ -18,6 +18,8 @@
|
||||
|
||||
namespace osg {
|
||||
|
||||
template<typename T> class observer_ptr;
|
||||
|
||||
/** Smart pointer for handling referenced counted objects.*/
|
||||
template<class T>
|
||||
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<class Other> ref_ptr(const ref_ptr<Other>& rp) : _ptr(rp._ptr) { if (_ptr) _ptr->ref(); }
|
||||
|
||||
ref_ptr(observer_ptr<T>& optr) : _ptr(0) { optr.lock(*this); }
|
||||
~ref_ptr() { if (_ptr) _ptr->unref(); _ptr = 0; }
|
||||
|
||||
ref_ptr& operator = (const ref_ptr& rp)
|
||||
|
@ -1612,8 +1612,8 @@ void DatabasePager::removeExpiredSubgraphs(const osg::FrameStamp& frameStamp)
|
||||
itr != _activePagedLODList.end();
|
||||
)
|
||||
{
|
||||
osg::ref_ptr<osg::PagedLOD> plod;
|
||||
if (itr->lock(plod))
|
||||
osg::ref_ptr<osg::PagedLOD> 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<osg::PagedLOD> plod;
|
||||
if (itr->lock(plod))
|
||||
osg::ref_ptr<osg::PagedLOD> 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<numToPrune;
|
||||
)
|
||||
{
|
||||
osg::ref_ptr<osg::PagedLOD> plod;
|
||||
if (itr->lock(plod) && countPagedLODsVisitor._pagedLODs.count(plod.get())==0)
|
||||
osg::ref_ptr<osg::PagedLOD> 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<numToPrune;
|
||||
)
|
||||
{
|
||||
osg::ref_ptr<osg::PagedLOD> plod;
|
||||
if (itr->lock(plod) && countPagedLODsVisitor._pagedLODs.count(plod.get())==0)
|
||||
osg::ref_ptr<osg::PagedLOD> plod(*itr);
|
||||
if (plod.valid() && countPagedLODsVisitor._pagedLODs.count(plod.get())==0)
|
||||
{
|
||||
countPagedLODsVisitor.removeExpiredChildrenAndCountPagedLODs(plod.get(), expiryTime, expiryFrame, childrenRemoved);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user