Revert memory leak commits

5f7001e: "Added a new branch"
01456ed: "Fixed a lot of memory leaks"
dac4493: "Fixed all remaining memory leaks that I could figure out"
0792db7: "Removed the smnew macro and the call to _CrtSetDbgFlag()"

Some of these caused destructor-time problems due to static initialization
order fiasco and related issues.  Notably, the program would no longer exit on
OSX and had to be killed.

There were probably legitimate fixes in here, but since these are monolithic
commits it's too much work to extract them now.  Let's reapply them
individually and in the forward direction.
This commit is contained in:
Devin J. Pohly
2013-04-27 00:05:14 -04:00
parent ef9c5294a0
commit feb919f0bf
33 changed files with 182 additions and 266 deletions
+10 -17
View File
@@ -52,18 +52,15 @@ static LocalizedString ON ( "ScreenDebugOverlay", "on" );
static LocalizedString OFF ( "ScreenDebugOverlay", "off" );
class IDebugLine;
vector<IDebugLine*> & GetSubscribers()
{
static vector<IDebugLine*> subscribers;
return subscribers;
}
static vector<IDebugLine*> *g_pvpSubscribers = NULL;
class IDebugLine
{
public:
IDebugLine()
{
GetSubscribers().push_back( this );
if( g_pvpSubscribers == NULL )
g_pvpSubscribers = new vector<IDebugLine*>;
g_pvpSubscribers->push_back( this );
}
virtual ~IDebugLine() { }
enum Type { all_screens, gameplay_only };
@@ -218,7 +215,7 @@ void ScreenDebugOverlay::Init()
map<RString,int> iNextDebugButton;
int iNextGameplayButton = 0;
FOREACH( IDebugLine*, GetSubscribers(), p )
FOREACH( IDebugLine*, *g_pvpSubscribers, p )
{
RString sPageName = (*p)->GetPageName();
@@ -274,7 +271,7 @@ void ScreenDebugOverlay::Init()
this->AddChild( p );
}
FOREACH_CONST( IDebugLine*, GetSubscribers(), p )
FOREACH_CONST( IDebugLine*, *g_pvpSubscribers, p )
{
{
BitmapText *bt = new BitmapText;
@@ -353,15 +350,13 @@ void ScreenDebugOverlay::UpdateText()
m_vptextPages[iPage]->PlayCommand( (iPage == m_iCurrentPage) ? "GainFocus" : "LoseFocus" );
}
vector<IDebugLine*> & subscribers = GetSubscribers();
// todo: allow changing of various spacing/location things -aj
int iOffset = 0;
FOREACH_CONST( IDebugLine*, subscribers, p )
FOREACH_CONST( IDebugLine*, *g_pvpSubscribers, p )
{
RString sPageName = (*p)->GetPageName();
int i = p-subscribers.begin();
int i = p-g_pvpSubscribers->begin();
float fY = LINE_START_Y + iOffset * LINE_SPACING;
@@ -452,13 +447,11 @@ bool ScreenDebugOverlay::Input( const InputEventPlus &input )
return true;
}
vector<IDebugLine*> & subscribers = GetSubscribers();
FOREACH_CONST( IDebugLine*, subscribers, p )
FOREACH_CONST( IDebugLine*, *g_pvpSubscribers, p )
{
RString sPageName = (*p)->GetPageName();
int i = p-subscribers.begin();
int i = p-g_pvpSubscribers->begin();
// Gameplay buttons are available only in gameplay. Non-gameplay buttons
// are only available when the screen is displayed.