From 5e301ba17c0b73c52189bac329b20143213817bd Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Mon, 18 Jun 2012 16:21:13 +0100 Subject: [PATCH] Controllers should free their callbacks and views --- src/console/ConsoleController.cpp | 7 ++++++- src/game/GameController.cpp | 1 + src/localbrowser/LocalBrowserController.cpp | 7 ++++++- src/login/LoginController.cpp | 1 + src/options/OptionsController.cpp | 3 +++ src/preview/PreviewController.cpp | 3 +++ src/render/RenderController.cpp | 1 + src/search/SearchController.cpp | 1 + src/ssave/SSaveController.cpp | 4 ++++ src/tags/TagsController.cpp | 7 ++++++- 10 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/console/ConsoleController.cpp b/src/console/ConsoleController.cpp index 7f1975d14..618137db3 100644 --- a/src/console/ConsoleController.cpp +++ b/src/console/ConsoleController.cpp @@ -70,6 +70,11 @@ ConsoleView * ConsoleController::GetView() } ConsoleController::~ConsoleController() { - // TODO Auto-generated destructor stub + if(ui::Engine::Ref().GetWindow() == consoleView) + ui::Engine::Ref().CloseWindow(); + if(callback) + delete callback; + delete consoleModel; + delete consoleView; } diff --git a/src/game/GameController.cpp b/src/game/GameController.cpp index 3031fb622..df5bf6880 100644 --- a/src/game/GameController.cpp +++ b/src/game/GameController.cpp @@ -161,6 +161,7 @@ GameController::~GameController() ui::Engine::Ref().CloseWindow(); } delete gameModel; + delete gameView; } GameView * GameController::GetView() diff --git a/src/localbrowser/LocalBrowserController.cpp b/src/localbrowser/LocalBrowserController.cpp index a66715a63..7eca5d31c 100644 --- a/src/localbrowser/LocalBrowserController.cpp +++ b/src/localbrowser/LocalBrowserController.cpp @@ -130,6 +130,11 @@ void LocalBrowserController::Exit() } LocalBrowserController::~LocalBrowserController() { - // TODO Auto-generated destructor stub + if(ui::Engine::Ref().GetWindow() == browserView) + ui::Engine::Ref().CloseWindow(); + if(callback) + delete callback; + delete localBrowserModel; + delete localBrowserView; } diff --git a/src/login/LoginController.cpp b/src/login/LoginController.cpp index af1a66a8e..a44e9ea13 100644 --- a/src/login/LoginController.cpp +++ b/src/login/LoginController.cpp @@ -49,5 +49,6 @@ LoginController::~LoginController() { ui::Engine::Ref().CloseWindow(); } delete loginModel; + delete loginView; } diff --git a/src/options/OptionsController.cpp b/src/options/OptionsController.cpp index 85f2a2ffc..f00731637 100644 --- a/src/options/OptionsController.cpp +++ b/src/options/OptionsController.cpp @@ -70,5 +70,8 @@ OptionsController::~OptionsController() { ui::Engine::Ref().CloseWindow(); } delete model; + delete view; + if(callback) + delete callback; } diff --git a/src/preview/PreviewController.cpp b/src/preview/PreviewController.cpp index 6490b502f..22913d7bc 100644 --- a/src/preview/PreviewController.cpp +++ b/src/preview/PreviewController.cpp @@ -103,5 +103,8 @@ PreviewController::~PreviewController() { ui::Engine::Ref().CloseWindow(); } delete previewModel; + delete previewView; + if(callback) + delete callback; } diff --git a/src/render/RenderController.cpp b/src/render/RenderController.cpp index 25e698f0c..75227cd0c 100644 --- a/src/render/RenderController.cpp +++ b/src/render/RenderController.cpp @@ -64,5 +64,6 @@ RenderController::~RenderController() { if(callback) delete callback; delete renderModel; + delete renderView; } diff --git a/src/search/SearchController.cpp b/src/search/SearchController.cpp index aff9636f2..68fe978a5 100644 --- a/src/search/SearchController.cpp +++ b/src/search/SearchController.cpp @@ -89,6 +89,7 @@ SearchController::~SearchController() ui::Engine::Ref().CloseWindow(); } delete searchModel; + delete searchView; } void SearchController::DoSearch(std::string query) diff --git a/src/ssave/SSaveController.cpp b/src/ssave/SSaveController.cpp index 3a6c3d4ef..5f3793391 100644 --- a/src/ssave/SSaveController.cpp +++ b/src/ssave/SSaveController.cpp @@ -51,5 +51,9 @@ void SSaveController::Exit() SSaveController::~SSaveController() { if(ui::Engine::Ref().GetWindow() == ssaveView) ui::Engine::Ref().CloseWindow(); + delete ssaveModel; + delete ssaveView; + if(callback) + delete callback; } diff --git a/src/tags/TagsController.cpp b/src/tags/TagsController.cpp index 26596fb67..845c50f19 100644 --- a/src/tags/TagsController.cpp +++ b/src/tags/TagsController.cpp @@ -50,6 +50,11 @@ void TagsController::Exit() } TagsController::~TagsController() { - // TODO Auto-generated destructor stub + if(ui::Engine::Ref().GetWindow() == tagsView) + ui::Engine::Ref().CloseWindow(); + delete tagsModel; + delete tagsView; + if(callback) + delete callback; }