From 7ffaa421d184ef63c9e34fa80b2438d1ec670161 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Mon, 18 Jun 2012 16:43:40 +0100 Subject: [PATCH] GameModel manages currentSave instance --- src/game/GameController.cpp | 2 +- src/game/GameModel.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/game/GameController.cpp b/src/game/GameController.cpp index df5bf6880..e681331d9 100644 --- a/src/game/GameController.cpp +++ b/src/game/GameController.cpp @@ -38,7 +38,7 @@ public: { try { - cc->gameModel->SetSave(new SaveInfo(*(cc->search->GetLoadedSave()))); + cc->gameModel->SetSave(cc->search->GetLoadedSave()); } catch(GameModelException & ex) { diff --git a/src/game/GameModel.cpp b/src/game/GameModel.cpp index cf9324b37..2a18d6b6e 100644 --- a/src/game/GameModel.cpp +++ b/src/game/GameModel.cpp @@ -182,6 +182,8 @@ GameModel::~GameModel() delete clipboard; if(stamp) delete stamp; + if(currentSave) + delete currentSave; //if(activeTools) // delete[] activeTools; } @@ -279,7 +281,11 @@ void GameModel::SetSave(SaveInfo * newSave) { if(currentSave != newSave) delete currentSave; - currentSave = newSave; + if(newSave == NULL) + currentSave = NULL; + else if(currentSave != newSave) + currentSave = new SaveInfo(*newSave); + if(currentSave && currentSave->GetGameSave()) { GameSave * saveData = currentSave->GetGameSave();