Skip to content

Commit 9ed5455

Browse files
committed
Fix CCore memory leaks
1 parent 8779c72 commit 9ed5455

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

Client/core/CCore.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ CCore::CCore()
146146
// Setup our hooks.
147147
ApplyHooks();
148148

149+
m_pModelCacheManager = nullptr;
150+
m_iDummyProgressValue = 0;
151+
m_DummyProgressTimerHandle = NULL;
152+
m_bDummyProgressUpdateAlways = false;
153+
149154
m_iUnminimizeFrameCounter = 0;
150155
m_bDidRecreateRenderTargets = false;
151156
m_fMinStreamingMemory = 0;
@@ -187,10 +192,27 @@ CCore::~CCore()
187192
// Remove input hook
188193
CMessageLoopHook::GetSingleton().RemoveHook();
189194

195+
if (m_bWindowsTimerEnabled)
196+
{
197+
KillTimer(GetHookedWindow(), IDT_TIMER1);
198+
m_bWindowsTimerEnabled = false;
199+
}
200+
201+
extern int ms_iDummyProgressTimerCounter;
202+
203+
if (m_DummyProgressTimerHandle != NULL)
204+
{
205+
DeleteTimerQueueTimer(NULL, m_DummyProgressTimerHandle, INVALID_HANDLE_VALUE);
206+
m_DummyProgressTimerHandle = NULL;
207+
ms_iDummyProgressTimerCounter = 0;
208+
}
209+
190210
// Delete the mod manager
191211
delete m_pModManager;
192212
SAFE_DELETE(m_pMessageBox);
193213

214+
SAFE_DELETE(m_pModelCacheManager);
215+
194216
// Destroy early subsystems
195217
m_bModulesLoaded = false;
196218
DestroyNetwork();
@@ -225,6 +247,8 @@ CCore::~CCore()
225247
DestroyGUI();
226248
DestroyXML();
227249

250+
SAFE_DELETE(g_pLocalization);
251+
228252
// Delete keybinds
229253
delete m_pKeyBinds;
230254

@@ -1072,6 +1096,16 @@ void CCore::CreateXML()
10721096
if (!m_pConfigFile)
10731097
{
10741098
assert(false);
1099+
1100+
if (m_pXML)
1101+
{
1102+
using PFNReleaseXMLInterface = void (*)();
1103+
if (auto pfnRelease = reinterpret_cast<PFNReleaseXMLInterface>(m_XMLModule.GetFunctionPointer("ReleaseXMLInterface")))
1104+
pfnRelease();
1105+
}
1106+
1107+
m_pXML = NULL;
1108+
m_XMLModule.UnloadModule();
10751109
return;
10761110
}
10771111

@@ -1123,10 +1157,14 @@ void CCore::DestroyXML()
11231157
{
11241158
SaveConfig(true);
11251159
delete m_pConfigFile;
1160+
m_pConfigFile = nullptr;
11261161
}
11271162

11281163
if (m_pXML)
11291164
{
1165+
using PFNReleaseXMLInterface = void (*)();
1166+
if (auto pfnRelease = reinterpret_cast<PFNReleaseXMLInterface>(m_XMLModule.GetFunctionPointer("ReleaseXMLInterface")))
1167+
pfnRelease();
11301168
m_pXML = NULL;
11311169
}
11321170

0 commit comments

Comments
 (0)