Fixed a lot of memory leaks caused by static globals never getting

deleted and some other objects not getting deleted properly due to missing
destructors.
This commit is contained in:
Shenjoku
2013-04-18 21:17:57 -07:00
parent 5f7001ef0a
commit 01456ed0b9
29 changed files with 239 additions and 171 deletions
+8 -4
View File
@@ -4,7 +4,11 @@
#include "RageUtil.h"
#include "SubscriptionManager.h"
static SubscriptionManager<LocalizedString> m_Subscribers;
SubscriptionManager<LocalizedString> & GetSubscribers()
{
static SubscriptionManager<LocalizedString> subscribers;
return subscribers;
}
class LocalizedStringImplDefault: public ILocalizedStringImpl
{
@@ -27,7 +31,7 @@ static LocalizedString::MakeLocalizer g_pMakeLocalizedStringImpl = LocalizedStri
void LocalizedString::RegisterLocalizer( MakeLocalizer pFunc )
{
g_pMakeLocalizedStringImpl = pFunc;
FOREACHS( LocalizedString*, *m_Subscribers.m_pSubscribers, l )
FOREACHS( LocalizedString*, GetSubscribers().m_pSubscribers, l )
{
LocalizedString *pLoc = *l;
pLoc->CreateImpl();
@@ -36,7 +40,7 @@ void LocalizedString::RegisterLocalizer( MakeLocalizer pFunc )
LocalizedString::LocalizedString( const RString& sGroup, const RString& sName )
{
m_Subscribers.Subscribe( this );
GetSubscribers().Subscribe( this );
m_sGroup = sGroup;
m_sName = sName;
@@ -47,7 +51,7 @@ LocalizedString::LocalizedString( const RString& sGroup, const RString& sName )
LocalizedString::~LocalizedString()
{
m_Subscribers.Unsubscribe( this );
GetSubscribers().Unsubscribe( this );
SAFE_DELETE( m_pImpl );
}