Added a check to the destructor of Referenced so that it detects referenced
objects that are deleted whilest still having a positive _refCount, such as when a object has been deleted on the stack, yet other references still exist for it. Have put the desctructor implementation in Object.cpp to avoid adding yet another file with only a couple of lines of code in.
This commit is contained in:
@@ -6,7 +6,6 @@
|
||||
#define OSG_REFERENCED 1
|
||||
|
||||
#include <osg/Export>
|
||||
#include <set>
|
||||
|
||||
namespace osg {
|
||||
|
||||
@@ -32,7 +31,7 @@ class SG_EXPORT Referenced
|
||||
inline const int referenceCount() const { return _refCount; }
|
||||
|
||||
protected:
|
||||
virtual ~Referenced() {}
|
||||
virtual ~Referenced();
|
||||
mutable int _refCount;
|
||||
|
||||
};
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
#include <osg/Object>
|
||||
#include <osg/Notify>
|
||||
#include <typeinfo>
|
||||
|
||||
using namespace osg;
|
||||
|
||||
Referenced::~Referenced()
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Object::Object(const Object&,const CopyOp&):
|
||||
Referenced() {}
|
||||
|
||||
Reference in New Issue
Block a user