diff --git a/Subtrees/beast/modules/beast_core/diagnostic/beast_LeakChecked.cpp b/Subtrees/beast/modules/beast_core/diagnostic/beast_LeakChecked.cpp index dbff127934..a0694dd647 100644 --- a/Subtrees/beast/modules/beast_core/diagnostic/beast_LeakChecked.cpp +++ b/Subtrees/beast/modules/beast_core/diagnostic/beast_LeakChecked.cpp @@ -89,6 +89,31 @@ void LeakCheckedBase::CounterBase::checkForLeaks () //------------------------------------------------------------------------------ +void LeakCheckedBase::reportDanglingPointer (char const* objectName) +{ + /* If you hit this, then you've managed to delete more instances + of this class than you've created. That indicates that you're + deleting some dangling pointers. + + Note that although this assertion will have been triggered + during a destructor, it might not be this particular deletion + that's at fault - the incorrect one may have happened at an + earlier point in the program, and simply not been detected + until now. + + Most errors like this are caused by using old-fashioned, + non-RAII techniques for your object management. Tut, tut. + Always, always use ScopedPointers, OwnedArrays, + ReferenceCountedObjects, etc, and avoid the 'delete' operator + at all costs! + */ + DBG ("Dangling pointer deletion: " << objectName); + + bassertfalse; +} + +//------------------------------------------------------------------------------ + void LeakCheckedBase::checkForLeaks () { CounterBase::Singleton::getInstance ().checkForLeaks (); diff --git a/Subtrees/beast/modules/beast_core/diagnostic/beast_LeakChecked.h b/Subtrees/beast/modules/beast_core/diagnostic/beast_LeakChecked.h index f25a649705..4d84722422 100644 --- a/Subtrees/beast/modules/beast_core/diagnostic/beast_LeakChecked.h +++ b/Subtrees/beast/modules/beast_core/diagnostic/beast_LeakChecked.h @@ -58,6 +58,9 @@ protected: Atomic m_count; }; +protected: + static void reportDanglingPointer (char const* objectName); + private: friend class PerformedAtExit::ExitHook; @@ -89,25 +92,7 @@ protected: { if (getCounter ().decrement () < 0) { - /* If you hit this, then you've managed to delete more instances - of this class than you've created. That indicates that you're - deleting some dangling pointers. - - Note that although this assertion will have been triggered - during a destructor, it might not be this particular deletion - that's at fault - the incorrect one may have happened at an - earlier point in the program, and simply not been detected - until now. - - Most errors like this are caused by using old-fashioned, - non-RAII techniques for your object management. Tut, tut. - Always, always use ScopedPointers, OwnedArrays, - ReferenceCountedObjects, etc, and avoid the 'delete' operator - at all costs! - */ - DBG ("Dangling pointer deletion: " << getLeakCheckedName ()); - - bassertfalse; + reportDanglingPointer (getLeakCheckedName ()); } }