Engine: introduced deleteHelper() function

The new deleteHelper() template function takes a pointer, saves it
to a temporary, sets the passed pointer to NULL and then deletes the
object it was referring to before. This way we can spot bugs caused by
undesired references to global objects at shutdown more easily.
This commit is contained in:
Tobias Doerffel
2010-05-21 13:24:37 +02:00
parent a9abdc3e75
commit fe7d5e3d5a
3 changed files with 35 additions and 35 deletions

View File

@@ -1,7 +1,7 @@
/*
* engine.h - engine-system of LMMS
*
* Copyright (c) 2006-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2006-2010 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -207,6 +207,16 @@ public:
}
private:
// small helper function which sets the pointer to NULL before actually deleting
// the object it refers to
template<class T>
static inline void deleteHelper( T * * ptr )
{
T * tmp = *ptr;
*ptr = NULL;
delete tmp;
}
static bool s_hasGUI;
static bool s_suppressMessages;
static float s_framesPerTick;