From ff571d2690fb3c3f6c4a8dacc79ad3e050001d15 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 7 Feb 2002 01:11:20 +0000 Subject: [PATCH] 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. --- include/osg/Referenced | 3 +-- src/osg/Object.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/osg/Referenced b/include/osg/Referenced index 2579379cc..ea01a07a3 100644 --- a/include/osg/Referenced +++ b/include/osg/Referenced @@ -6,7 +6,6 @@ #define OSG_REFERENCED 1 #include -#include 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; }; diff --git a/src/osg/Object.cpp b/src/osg/Object.cpp index ae9dde005..6b07e7ae3 100644 --- a/src/osg/Object.cpp +++ b/src/osg/Object.cpp @@ -1,6 +1,18 @@ #include +#include +#include using namespace osg; +Referenced::~Referenced() +{ + if (_refCount>0) + { + notify(WARN)<<"Warning: deleting still referenced object "<