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.
(cherry picked from commit fe7d5e3d5a)
This commit is contained in:
Tobias Doerffel
2010-05-21 13:24:37 +02:00
parent 95b0c827d1
commit 488337f6eb
3 changed files with 36 additions and 34 deletions

View File

@@ -1,8 +1,8 @@
/*
* engine.h - engine-system of LMMS
*
* Copyright (c) 2006-2008 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
*
* This program is free software; you can redistribute it and/or
@@ -160,6 +160,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;