Added a DeleteHandler into osg::Referenced so that it can delete objects
via a seperate delete handler. Useful for making unref()/ref() thread safe if the users needs to address this issue.
This commit is contained in:
@@ -1,28 +1,12 @@
|
||||
#include <osg/Object>
|
||||
#include <osg/Notify>
|
||||
#include <typeinfo>
|
||||
|
||||
using namespace osg;
|
||||
|
||||
#ifdef OSG_COMPILE_UNIT_TESTS
|
||||
int Referenced::_createdCount = 0;
|
||||
int Referenced::_deletedCount = 0;
|
||||
#endif
|
||||
|
||||
Referenced::~Referenced()
|
||||
namespace osg
|
||||
{
|
||||
if (_refCount>0)
|
||||
{
|
||||
notify(WARN)<<"Warning: deleting still referenced object "<<this<<" of type '"<<typeid(this).name()<<"'"<<std::endl;
|
||||
notify(WARN)<<" the final reference count was "<<_refCount<<", memory corruption possible."<<std::endl;
|
||||
}
|
||||
#ifdef OSG_COMPILE_UNIT_TESTS
|
||||
_deletedCount ++;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Object::Object(const Object& obj,const CopyOp& copyop):
|
||||
Referenced(),
|
||||
_dataVariance(obj._dataVariance),
|
||||
_userData(copyop(obj._userData.get())) {}
|
||||
|
||||
|
||||
}; // end of namespace osg
|
||||
|
||||
Reference in New Issue
Block a user