Skip to content

Commit

Permalink
Fix memory leak with pauseMngr.
Browse files Browse the repository at this point in the history
  • Loading branch information
intorr committed Feb 15, 2018
1 parent 9677d8a commit c51814e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
10 changes: 2 additions & 8 deletions src/xrCore/FTimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,9 @@ void CStatTimer::FrameEnd() {
result = 0.99f * result + 0.01f * time;
}

XRCORE_API pauseMngr* g_pauseMngr()
XRCORE_API pauseMngr& g_pauseMngr()
{
static pauseMngr* manager = nullptr;

if (!manager)
{
manager = new pauseMngr();
}

static pauseMngr manager;
return manager;
}

Expand Down
6 changes: 3 additions & 3 deletions src/xrCore/FTimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class XRCORE_API pauseMngr : Noncopyable
void UnRegister(CTimer_paused& t);
};

extern XRCORE_API pauseMngr* g_pauseMngr();
extern XRCORE_API pauseMngr& g_pauseMngr();

class XRCORE_API CTimerBase
{
Expand Down Expand Up @@ -142,8 +142,8 @@ class XRCORE_API CTimer_paused_ex : public CTimer
class XRCORE_API CTimer_paused : public CTimer_paused_ex
{
public:
CTimer_paused() { g_pauseMngr()->Register(*this); }
virtual ~CTimer_paused() { g_pauseMngr()->UnRegister(*this); }
CTimer_paused() { g_pauseMngr().Register(*this); }
virtual ~CTimer_paused() { g_pauseMngr().UnRegister(*this); }
};

extern XRCORE_API bool g_bEnableStatGather;
Expand Down
8 changes: 4 additions & 4 deletions src/xrEngine/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ void CRenderDevice::Pause(BOOL bOn, BOOL bTimer, BOOL bSound, LPCSTR reason)
TRUE;
if (bTimer && (!g_pGamePersistent || g_pGamePersistent->CanBePaused()))
{
g_pauseMngr()->Pause(TRUE);
g_pauseMngr().Pause(TRUE);
#ifdef DEBUG
if (!xr_strcmp(reason, "li_pause_key_no_clip"))
TimerGlobal.Pause(FALSE);
Expand All @@ -422,10 +422,10 @@ void CRenderDevice::Pause(BOOL bOn, BOOL bTimer, BOOL bSound, LPCSTR reason)
}
else
{
if (bTimer && g_pauseMngr()->Paused())
if (bTimer && g_pauseMngr().Paused())
{
fTimeDelta = EPS_S + EPS_S;
g_pauseMngr()->Pause(FALSE);
g_pauseMngr().Pause(FALSE);
}
if (bSound)
{
Expand All @@ -441,7 +441,7 @@ void CRenderDevice::Pause(BOOL bOn, BOOL bTimer, BOOL bSound, LPCSTR reason)
}
}

BOOL CRenderDevice::Paused() { return g_pauseMngr()->Paused(); }
BOOL CRenderDevice::Paused() { return g_pauseMngr().Paused(); }
void CRenderDevice::OnWM_Activate(WPARAM wParam, LPARAM /*lParam*/)
{
u16 fActive = LOWORD(wParam);
Expand Down

0 comments on commit c51814e

Please sign in to comment.