mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-29 10:49:53 +02:00
a few more memory leak fixes
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
@@ -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)
|
||||
|
@@ -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);
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user