# HG changeset patch # User koryspansel # Date 1317975328 25200 # Node ID 8e7ebab350e7a1bee56fa43bf460d6c7811cebd8 # Parent f7095bce01cffdade2e1d49ed65cf37c9c1ce169 Clean up memory leaks diff -r f7095bce01cf -r 8e7ebab350e7 LightClone/Source/ActionPanel.cpp --- a/LightClone/Source/ActionPanel.cpp Wed Oct 05 22:55:46 2011 -0700 +++ b/LightClone/Source/ActionPanel.cpp Fri Oct 07 01:15:28 2011 -0700 @@ -18,6 +18,14 @@ } /* + * ActionPanel + */ +ActionPanel::~ActionPanel() +{ + delete[] pSlot; +} + +/* * Initialize */ ErrorCode ActionPanel::Initialize(ServiceProvider* pServiceProvider) diff -r f7095bce01cf -r 8e7ebab350e7 LightClone/Source/ActionPanel.h --- a/LightClone/Source/ActionPanel.h Wed Oct 05 22:55:46 2011 -0700 +++ b/LightClone/Source/ActionPanel.h Fri Oct 07 01:15:28 2011 -0700 @@ -63,6 +63,11 @@ ActionPanel(uint32 nWidth, uint32 nHeight); /* + * ActionPanel + */ + ~ActionPanel(); + + /* * Initialize */ virtual ErrorCode Initialize(ServiceProvider* pServiceProvider); diff -r f7095bce01cf -r 8e7ebab350e7 LightClone/Source/Core.h --- a/LightClone/Source/Core.h Wed Oct 05 22:55:46 2011 -0700 +++ b/LightClone/Source/Core.h Fri Oct 07 01:15:28 2011 -0700 @@ -5,11 +5,17 @@ #ifndef __CORE_H__ #define __CORE_H__ +#define CRTDBG_MAP_ALLOC +#include +#include + #include "Types.h" #include "Trace.h" #include "Debug.h" #include #include +#include +#include /* * WorldState diff -r f7095bce01cf -r 8e7ebab350e7 LightClone/Source/GuiEventMap.cpp --- a/LightClone/Source/GuiEventMap.cpp Wed Oct 05 22:55:46 2011 -0700 +++ b/LightClone/Source/GuiEventMap.cpp Fri Oct 07 01:15:28 2011 -0700 @@ -11,6 +11,20 @@ { } +/* + * ~GuiEventMap + */ +GuiEventMap::~GuiEventMap() +{ + GuiEventHashMap::Iterator kEvent = kMap.Begin(); + GuiEventHashMap::Iterator kEventEnd = kMap.End(); + + for(; kEvent != kEventEnd; ++kEvent) + { + delete *kEvent; + } +} + /* * Fire */ diff -r f7095bce01cf -r 8e7ebab350e7 LightClone/Source/GuiEventMap.h --- a/LightClone/Source/GuiEventMap.h Wed Oct 05 22:55:46 2011 -0700 +++ b/LightClone/Source/GuiEventMap.h Fri Oct 07 01:15:28 2011 -0700 @@ -15,9 +15,14 @@ class GuiEventMap { /* + * GuiEventHashMap + */ + typedef HashMap, GuiEvent*, FixedString<>::Hash> GuiEventHashMap; + + /* * kMap */ - HashMap, GuiEvent*, FixedString<>::Hash> kMap; + GuiEventHashMap kMap; public: @@ -26,6 +31,11 @@ */ GuiEventMap(); + /* + * ~GuiEventMap + */ + ~GuiEventMap(); + /* * Subscribe */ diff -r f7095bce01cf -r 8e7ebab350e7 LightClone/Source/GuiInterface.cpp --- a/LightClone/Source/GuiInterface.cpp Wed Oct 05 22:55:46 2011 -0700 +++ b/LightClone/Source/GuiInterface.cpp Fri Oct 07 01:15:28 2011 -0700 @@ -14,6 +14,14 @@ } /* + * ~GuiInterface + */ +GuiInterface::~GuiInterface() +{ + delete pCursor; +} + +/* * Initialize */ ErrorCode GuiInterface::Initialize(ServiceProvider* pServiceProvider) @@ -54,6 +62,9 @@ */ void GuiInterface::Terminate() { + if(pCursor) + pCursor->Terminate(); + GuiElement::Terminate(); } diff -r f7095bce01cf -r 8e7ebab350e7 LightClone/Source/GuiInterface.h --- a/LightClone/Source/GuiInterface.h Wed Oct 05 22:55:46 2011 -0700 +++ b/LightClone/Source/GuiInterface.h Fri Oct 07 01:15:28 2011 -0700 @@ -60,6 +60,11 @@ GuiInterface(); /* + * ~GuiInterface + */ + ~GuiInterface(); + + /* * Initialize */ ErrorCode Initialize(ServiceProvider* pServiceProvider); diff -r f7095bce01cf -r 8e7ebab350e7 LightClone/Source/Loader.cpp --- a/LightClone/Source/Loader.cpp Wed Oct 05 22:55:46 2011 -0700 +++ b/LightClone/Source/Loader.cpp Fri Oct 07 01:15:28 2011 -0700 @@ -27,17 +27,8 @@ */ Loader::~Loader() { - if(pType) - { - delete[] pType; - pType = 0; - } - - if(pHeight) - { - delete[] pHeight; - pHeight = 0; - } + delete[] pType; + delete[] pHeight; } /* @@ -45,17 +36,11 @@ */ ErrorCode Loader::Load(const char* pName) { - if(pType) - { - delete[] pType; - pType = 0; - } + delete[] pType; + pType = 0; - if(pHeight) - { - delete[] pHeight; - pHeight = 0; - } + delete[] pHeight; + pHeight = 0; Buffer kBuffer = LoadFile(pName); diff -r f7095bce01cf -r 8e7ebab350e7 LightClone/Source/Main.cpp --- a/LightClone/Source/Main.cpp Wed Oct 05 22:55:46 2011 -0700 +++ b/LightClone/Source/Main.cpp Fri Oct 07 01:15:28 2011 -0700 @@ -2,13 +2,13 @@ * Main */ -#include -#include #include "Mediator.h" -#include "VirtualMachine.h" -#include "Trace.h" int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE, LPTSTR, int) { + #if defined(_DEBUG) + _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); + #endif + return Mediator().Run(); } \ No newline at end of file diff -r f7095bce01cf -r 8e7ebab350e7 LightClone/Source/Util.cpp --- a/LightClone/Source/Util.cpp Wed Oct 05 22:55:46 2011 -0700 +++ b/LightClone/Source/Util.cpp Fri Oct 07 01:15:28 2011 -0700 @@ -37,5 +37,5 @@ fclose(pFile); } - return Buffer(pData, nSize); + return Buffer(pData, nSize, false); } \ No newline at end of file diff -r f7095bce01cf -r 8e7ebab350e7 LightClone/Source/World.cpp --- a/LightClone/Source/World.cpp Wed Oct 05 22:55:46 2011 -0700 +++ b/LightClone/Source/World.cpp Fri Oct 07 01:15:28 2011 -0700 @@ -226,9 +226,6 @@ */ ErrorCode World::InitializeInterface(ServiceProvider* pServiceProvider) { - //ResourceManager* pResourceManager = (ResourceManager*)pServiceProvider->GetService("ResourceManager"); - //ASSERT(pResourceManager != NULL); - ErrorCode eCode = kInterface.Initialize(pServiceProvider); if(eCode == Error_Success) { diff -r f7095bce01cf -r 8e7ebab350e7 LightClone/ToDo.txt --- a/LightClone/ToDo.txt Wed Oct 05 22:55:46 2011 -0700 +++ b/LightClone/ToDo.txt Fri Oct 07 01:15:28 2011 -0700 @@ -11,4 +11,4 @@ 4. Help interface Bugs: -1. Fix gui element destruction +1. Fix DX resource leaks \ No newline at end of file