diff options
author | D G Turner | 2012-07-26 09:18:57 +0100 |
---|---|---|
committer | D G Turner | 2012-07-26 09:18:57 +0100 |
commit | f137c75e4619d5ae8a103bfb800018da38d0c552 (patch) | |
tree | 6c14361ada4b44ff34410dc33237d0f50371e656 | |
parent | 72adca69f327a1d6a6b6e0c09447d05a74151a8d (diff) | |
download | scummvm-rg350-f137c75e4619d5ae8a103bfb800018da38d0c552.tar.gz scummvm-rg350-f137c75e4619d5ae8a103bfb800018da38d0c552.tar.bz2 scummvm-rg350-f137c75e4619d5ae8a103bfb800018da38d0c552.zip |
TEENAGENT: Migrate deinit functions to constructor/destructors.
This removes a number of memory leaks.
-rw-r--r-- | engines/teenagent/resources.cpp | 5 | ||||
-rw-r--r-- | engines/teenagent/resources.h | 3 | ||||
-rw-r--r-- | engines/teenagent/teenagent.cpp | 32 | ||||
-rw-r--r-- | engines/teenagent/teenagent.h | 1 |
4 files changed, 19 insertions, 22 deletions
diff --git a/engines/teenagent/resources.cpp b/engines/teenagent/resources.cpp index bd09b08522..b91c8dc491 100644 --- a/engines/teenagent/resources.cpp +++ b/engines/teenagent/resources.cpp @@ -27,7 +27,10 @@ namespace TeenAgent { -void Resources::deinit() { +Resources::Resources() { +} + +Resources::~Resources() { off.close(); on.close(); ons.close(); diff --git a/engines/teenagent/resources.h b/engines/teenagent/resources.h index df1eb1d6d5..1d98fb6821 100644 --- a/engines/teenagent/resources.h +++ b/engines/teenagent/resources.h @@ -658,7 +658,8 @@ const uint16 dsAddr_finalCredits7 = 0xe488; // "programming..." class Resources { public: - void deinit(); + Resources(); + ~Resources(); bool loadArchives(const ADGameDescription *gd); void loadOff(Graphics::Surface &surface, byte *palette, int id); diff --git a/engines/teenagent/teenagent.cpp b/engines/teenagent/teenagent.cpp index a14fffd77f..acfc0cbc17 100644 --- a/engines/teenagent/teenagent.cpp +++ b/engines/teenagent/teenagent.cpp @@ -73,10 +73,20 @@ TeenAgentEngine::TeenAgentEngine(OSystem *system, const ADGameDescription *gd) } TeenAgentEngine::~TeenAgentEngine() { - delete music; delete dialog; - res->deinit(); + dialog = 0; + delete scene; + scene = 0; + delete inventory; + inventory = 0; + delete music; + music = 0; + _mixer->stopAll(); + use_hotspots.clear(); delete res; + res = 0; + + CursorMan.popCursor(); delete console; DebugMan.clearAllDebugChannels(); @@ -206,19 +216,6 @@ void TeenAgentEngine::init() { } } -void TeenAgentEngine::deinit() { - _mixer->stopAll(); - delete scene; - scene = NULL; - delete inventory; - inventory = NULL; - //delete music; - //music = NULL; - use_hotspots.clear(); - res->deinit(); - CursorMan.popCursor(); -} - Common::Error TeenAgentEngine::loadGameState(int slot) { debug(0, "loading from slot %d", slot); Common::ScopedPtr<Common::InSaveFile> in(_saveFileMan->openForLoading(Common::String::format("teenagent.%02d", slot))); @@ -579,10 +576,8 @@ Common::Error TeenAgentEngine::run() { Object *current_object = scene->findObject(mouse); while (_event->pollEvent(event)) { - if (event.type == Common::EVENT_RTL) { - deinit(); + if (event.type == Common::EVENT_RTL) return Common::kNoError; - } if ((!scene_busy && inventory->processEvent(event)) || scene->processEvent(event)) continue; @@ -702,7 +697,6 @@ Common::Error TeenAgentEngine::run() { } } while (!shouldQuit()); - deinit(); return Common::kNoError; } diff --git a/engines/teenagent/teenagent.h b/engines/teenagent/teenagent.h index c5518b0b48..0f078f155c 100644 --- a/engines/teenagent/teenagent.h +++ b/engines/teenagent/teenagent.h @@ -82,7 +82,6 @@ public: virtual bool hasFeature(EngineFeature f) const; void init(); - void deinit(); void examine(const Common::Point &point, Object *object); void use(Object *object); |