summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjacob1 <jfu614@gmail.com>2013-03-09 01:56:54 (GMT)
committer jacob1 <jfu614@gmail.com>2013-03-09 01:56:54 (GMT)
commitf9c219da93983ca0a3c5fc7e2f0579c4a44bca40 (patch)
tree401ba98898cc475eb5a29f927f9919dbb48c04c1 /src
parent89c784fcfa80900c7925da258e91feeee2a2ab96 (diff)
downloadpowder-f9c219da93983ca0a3c5fc7e2f0579c4a44bca40.zip
powder-f9c219da93983ca0a3c5fc7e2f0579c4a44bca40.tar.gz
a few more memory leak fixes
Diffstat (limited to 'src')
-rw-r--r--src/game/GameController.cpp16
-rw-r--r--src/game/GameModel.cpp12
-rw-r--r--src/game/Tool.cpp7
-rw-r--r--src/preview/PreviewModel.cpp6
4 files changed, 28 insertions, 13 deletions
diff --git a/src/game/GameController.cpp b/src/game/GameController.cpp
index 1e10b0e..993e768 100644
--- a/src/game/GameController.cpp
+++ b/src/game/GameController.cpp
@@ -196,6 +196,22 @@ GameController::~GameController()
{
ui::Engine::Ref().CloseWindow();
}
+ //deleted here because it refuses to be deleted when deleted from gameModel even with the same code
+ std::deque<Snapshot*> history = gameModel->GetHistory();
+ for(std::deque<Snapshot*>::iterator iter = history.begin(), end = history.end(); iter != end; ++iter)
+ {
+ delete *iter;
+ }
+ std::vector<QuickOption*> quickOptions = gameModel->GetQuickOptions();
+ for(std::vector<QuickOption*>::iterator iter = quickOptions.begin(), end = quickOptions.end(); iter != end; ++iter)
+ {
+ delete *iter;
+ }
+ std::vector<Notification*> notifications = gameModel->GetNotifications();
+ for(std::vector<Notification*>::iterator iter = notifications.begin(); iter != notifications.end(); ++iter)
+ {
+ delete *iter;
+ }
delete gameModel;
delete gameView;
}
diff --git a/src/game/GameModel.cpp b/src/game/GameModel.cpp
index 083f4bf..e687674 100644
--- a/src/game/GameModel.cpp
+++ b/src/game/GameModel.cpp
@@ -175,18 +175,6 @@ GameModel::~GameModel()
{
delete brushList[i];
}
- for(std::deque<Snapshot*>::iterator iter = history.begin(), end = history.end(); iter != end; ++iter)
- {
- delete *iter;
- }
- for(std::vector<QuickOption*>::iterator iter = quickOptions.begin(), end = quickOptions.end(); iter != end; ++iter)
- {
- delete *iter;
- }
- for(std::vector<Notification*>::iterator iter = notifications.begin(); iter != notifications.end(); ++iter)
- {
- delete *iter;
- }
delete sim;
delete ren;
if(placeSave)
diff --git a/src/game/Tool.cpp b/src/game/Tool.cpp
index b0ad67a..42f9b59 100644
--- a/src/game/Tool.cpp
+++ b/src/game/Tool.cpp
@@ -19,6 +19,7 @@ Tool::Tool(int id, string name, string description, int r, int g, int b, std::st
identifier(identifier)
{
}
+
VideoBuffer * Tool::GetTexture(int width, int height)
{
if(textureGen)
@@ -35,6 +36,7 @@ std::string Tool::GetIdentifier() { return identifier; }
string Tool::GetName() { return toolName; }
string Tool::GetDescription() { return toolDescription; }
Tool::~Tool() {}
+
void Tool::Click(Simulation * sim, Brush * brush, ui::Point position) { }
void Tool::Draw(Simulation * sim, Brush * brush, ui::Point position) {
sim->ToolBrush(position.X, position.Y, toolID, brush, strength);
@@ -47,6 +49,7 @@ void Tool::DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Po
}
void Tool::DrawFill(Simulation * sim, Brush * brush, ui::Point position) {};
+
ElementTool::ElementTool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int)):
Tool(id, name, description, r, g, b, identifier, textureGen)
{
@@ -126,6 +129,7 @@ void GolTool::DrawFill(Simulation * sim, Brush * brush, ui::Point position) {
sim->FloodParts(position.X, position.Y, PT_LIFE|(toolID<<8), -1, -1, 0);
}
+
WindTool::WindTool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int)):
Tool(id, name, description, r, g, b, identifier, textureGen)
{
@@ -163,7 +167,6 @@ void WindTool::DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui
}
}
void WindTool::DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) {}
-
void WindTool::DrawFill(Simulation * sim, Brush * brush, ui::Point position) {}
@@ -183,6 +186,7 @@ void Element_LIGH_Tool::Draw(Simulation * sim, Brush * brush, ui::Point position
}
}
+
Element_TESC_Tool::Element_TESC_Tool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int)):
ElementTool(id, name, description, r, g, b, identifier, textureGen)
{
@@ -204,6 +208,7 @@ void Element_TESC_Tool::DrawFill(Simulation * sim, Brush * brush, ui::Point posi
sim->FloodParts(position.X, position.Y, toolID | (radiusInfo << 8), -1, -1, 0);
}
+
void PlopTool::Click(Simulation * sim, Brush * brush, ui::Point position)
{
sim->create_part(-1, position.X, position.Y, toolID);
diff --git a/src/preview/PreviewModel.cpp b/src/preview/PreviewModel.cpp
index dd77374..cb8adfd 100644
--- a/src/preview/PreviewModel.cpp
+++ b/src/preview/PreviewModel.cpp
@@ -308,6 +308,12 @@ void PreviewModel::Update()
PreviewModel::~PreviewModel() {
if(save)
delete save;
+ if(saveComments)
+ {
+ for(int i = 0; i < saveComments->size(); i++)
+ delete saveComments->at(i);
+ saveComments->clear();
+ }
saveDataBuffer.clear();
}