diff --git a/src/xrCore/FTimer.cpp b/src/xrCore/FTimer.cpp index 5d6d652214a..7d6fc2c945a 100644 --- a/src/xrCore/FTimer.cpp +++ b/src/xrCore/FTimer.cpp @@ -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; } diff --git a/src/xrCore/FTimer.h b/src/xrCore/FTimer.h index 8868f069bc2..2097e2b95f2 100644 --- a/src/xrCore/FTimer.h +++ b/src/xrCore/FTimer.h @@ -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 { @@ -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; diff --git a/src/xrEngine/device.cpp b/src/xrEngine/device.cpp index 35bb8aaf727..5337518445b 100644 --- a/src/xrEngine/device.cpp +++ b/src/xrEngine/device.cpp @@ -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); @@ -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) { @@ -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);