Changed the ref_ptr<T> observer_ptr<>::lock() method to be
bool observer_ptr<>::lock(ref_ptr<T>&) to avoid the temporary ref_ptr<>'s being created and destroyed on the stack along with the associated ref/unref() operations
This commit is contained in:
@@ -100,8 +100,7 @@ bool ObserverNodePath::getRefNodePath(RefNodePath& refNodePath) const
|
||||
refNodePath.resize(_nodePath.size());
|
||||
for(unsigned int i=0; i<_nodePath.size(); ++i)
|
||||
{
|
||||
refNodePath[i] = _nodePath[i].lock();
|
||||
if (!refNodePath[i].valid())
|
||||
if (!_nodePath[i].lock(refNodePath[i]))
|
||||
{
|
||||
OSG_INFO<<"ObserverNodePath::getRefNodePath() node has been invalidated"<<std::endl;
|
||||
refNodePath.clear();
|
||||
|
||||
@@ -1612,8 +1612,8 @@ void DatabasePager::removeExpiredSubgraphs(const osg::FrameStamp& frameStamp)
|
||||
itr != _activePagedLODList.end();
|
||||
)
|
||||
{
|
||||
osg::ref_ptr<osg::PagedLOD> plod = itr->lock();
|
||||
if (plod.valid())
|
||||
osg::ref_ptr<osg::PagedLOD> plod;
|
||||
if (itr->lock(plod))
|
||||
{
|
||||
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 = itr->lock();
|
||||
if (plod.valid())
|
||||
osg::ref_ptr<osg::PagedLOD> plod;
|
||||
if (itr->lock(plod))
|
||||
{
|
||||
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 = itr->lock();
|
||||
if (plod.valid() && countPagedLODsVisitor._pagedLODs.count(plod.get())==0)
|
||||
osg::ref_ptr<osg::PagedLOD> plod;
|
||||
if (itr->lock(plod) && 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 = itr->lock();
|
||||
if (plod.valid() && countPagedLODsVisitor._pagedLODs.count(plod.get())==0)
|
||||
osg::ref_ptr<osg::PagedLOD> plod;
|
||||
if (itr->lock(plod) && countPagedLODsVisitor._pagedLODs.count(plod.get())==0)
|
||||
{
|
||||
countPagedLODsVisitor.removeExpiredChildrenAndCountPagedLODs(plod.get(), expiryTime, expiryFrame, childrenRemoved);
|
||||
|
||||
|
||||
@@ -561,10 +561,10 @@ BEGIN_OBJECT_REFLECTOR(osg::observer_ptr< osg::GraphicsContext >)
|
||||
____observer_ptr__C5_observer_ptr_R1,
|
||||
"",
|
||||
"");
|
||||
I_Method0(osg::ref_ptr< osg::GraphicsContext >, lock,
|
||||
I_Method1(bool, lock, IN, osg::ref_ptr< osg::GraphicsContext > &, rptr,
|
||||
Properties::NON_VIRTUAL,
|
||||
__ref_ptrT1_T___lock,
|
||||
"Create a ref_ptr from a observer_ptr. ",
|
||||
__bool__lock__ref_ptrT1_T__R1,
|
||||
"Assign the observer_ptr to a ref_ptr. ",
|
||||
"The ref_ptr will be valid if the referenced object hasn't been deleted and has a ref count > 0. ");
|
||||
I_Method0(osg::GraphicsContext *, get,
|
||||
Properties::NON_VIRTUAL,
|
||||
|
||||
@@ -251,10 +251,10 @@ BEGIN_OBJECT_REFLECTOR(osg::observer_ptr< osg::Node >)
|
||||
____observer_ptr__C5_observer_ptr_R1,
|
||||
"",
|
||||
"");
|
||||
I_Method0(osg::ref_ptr< osg::Node >, lock,
|
||||
I_Method1(bool, lock, IN, osg::ref_ptr< osg::Node > &, rptr,
|
||||
Properties::NON_VIRTUAL,
|
||||
__ref_ptrT1_T___lock,
|
||||
"Create a ref_ptr from a observer_ptr. ",
|
||||
__bool__lock__ref_ptrT1_T__R1,
|
||||
"Assign the observer_ptr to a ref_ptr. ",
|
||||
"The ref_ptr will be valid if the referenced object hasn't been deleted and has a ref count > 0. ");
|
||||
I_Method0(osg::Node *, get,
|
||||
Properties::NON_VIRTUAL,
|
||||
|
||||
@@ -969,10 +969,10 @@ BEGIN_OBJECT_REFLECTOR(osg::observer_ptr< osgWidget::Widget >)
|
||||
____observer_ptr__C5_observer_ptr_R1,
|
||||
"",
|
||||
"");
|
||||
I_Method0(osg::ref_ptr< osgWidget::Widget >, lock,
|
||||
I_Method1(bool, lock, IN, osg::ref_ptr< osgWidget::Widget > &, rptr,
|
||||
Properties::NON_VIRTUAL,
|
||||
__ref_ptrT1_T___lock,
|
||||
"Create a ref_ptr from a observer_ptr. ",
|
||||
__bool__lock__ref_ptrT1_T__R1,
|
||||
"Assign the observer_ptr to a ref_ptr. ",
|
||||
"The ref_ptr will be valid if the referenced object hasn't been deleted and has a ref count > 0. ");
|
||||
I_Method0(osgWidget::Widget *, get,
|
||||
Properties::NON_VIRTUAL,
|
||||
|
||||
@@ -971,10 +971,10 @@ BEGIN_OBJECT_REFLECTOR(osg::observer_ptr< osgWidget::Window >)
|
||||
____observer_ptr__C5_observer_ptr_R1,
|
||||
"",
|
||||
"");
|
||||
I_Method0(osg::ref_ptr< osgWidget::Window >, lock,
|
||||
I_Method1(bool, lock, IN, osg::ref_ptr< osgWidget::Window > &, rptr,
|
||||
Properties::NON_VIRTUAL,
|
||||
__ref_ptrT1_T___lock,
|
||||
"Create a ref_ptr from a observer_ptr. ",
|
||||
__bool__lock__ref_ptrT1_T__R1,
|
||||
"Assign the observer_ptr to a ref_ptr. ",
|
||||
"The ref_ptr will be valid if the referenced object hasn't been deleted and has a ref count > 0. ");
|
||||
I_Method0(osgWidget::Window *, get,
|
||||
Properties::NON_VIRTUAL,
|
||||
|
||||
Reference in New Issue
Block a user