From 68a32aa37607333d3d9a4ddb202a73cc01993000 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Sun, 30 Sep 2012 16:26:05 +0100 Subject: [PATCH] Pass points by value for drawing tools --- src/game/GameController.cpp | 8 ++++---- src/game/GameController.h | 2 +- src/game/GameView.cpp | 14 +++++++------- src/game/GameView.h | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/game/GameController.cpp b/src/game/GameController.cpp index 0ed9cf041..a1c4965da 100644 --- a/src/game/GameController.cpp +++ b/src/game/GameController.cpp @@ -401,7 +401,7 @@ void GameController::DrawFill(int toolSelection, ui::Point point) activeTool->DrawFill(sim, cBrush, point); } -void GameController::DrawPoints(int toolSelection, queue & pointQueue) +void GameController::DrawPoints(int toolSelection, queue & pointQueue) { Simulation * sim = gameModel->GetSimulation(); Tool * activeTool = gameModel->GetActiveTool(toolSelection); @@ -413,7 +413,7 @@ void GameController::DrawPoints(int toolSelection, queue & pointQueu { while(!pointQueue.empty()) { - delete pointQueue.front(); + //delete pointQueue.front(); pointQueue.pop(); } } @@ -427,8 +427,8 @@ void GameController::DrawPoints(int toolSelection, queue & pointQueu bool first = true; while(!pointQueue.empty()) { - ui::Point fPoint = *pointQueue.front(); - delete pointQueue.front(); + ui::Point fPoint = pointQueue.front(); + //delete pointQueue.front(); pointQueue.pop(); if(!first) { diff --git a/src/game/GameController.h b/src/game/GameController.h index dc95f8ebc..14dbccbb3 100644 --- a/src/game/GameController.h +++ b/src/game/GameController.h @@ -82,7 +82,7 @@ public: void AdjustBrushSize(int direction, bool logarithmic = false, bool xAxis = false, bool yAxis = false); void AdjustZoomSize(int direction, bool logarithmic = false); void ToolClick(int toolSelection, ui::Point point); - void DrawPoints(int toolSelection, queue & pointQueue); + void DrawPoints(int toolSelection, queue & pointQueue); void DrawRect(int toolSelection, ui::Point point1, ui::Point point2); void DrawLine(int toolSelection, ui::Point point1, ui::Point point2); void DrawFill(int toolSelection, ui::Point point); diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp index af9eaaa88..d952d5fab 100644 --- a/src/game/GameView.cpp +++ b/src/game/GameView.cpp @@ -146,7 +146,7 @@ public: GameView::GameView(): ui::Window(ui::Point(0, 0), ui::Point(XRES+BARSIZE, YRES+MENUSIZE)), - pointQueue(queue()), + pointQueue(queue()), isMouseDown(false), ren(NULL), activeBrush(NULL), @@ -926,8 +926,8 @@ void GameView::OnMouseMove(int x, int y, int dx, int dy) currentMouse = ui::Point(x, y); if(isMouseDown && drawMode == DrawPoints) { - pointQueue.push(new ui::Point(c->PointTranslate(ui::Point(x-dx, y-dy)))); - pointQueue.push(new ui::Point(c->PointTranslate(ui::Point(x, y)))); + pointQueue.push(ui::Point(c->PointTranslate(ui::Point(x-dx, y-dy)))); + pointQueue.push(ui::Point(c->PointTranslate(ui::Point(x, y)))); } } @@ -961,7 +961,7 @@ void GameView::OnMouseDown(int x, int y, unsigned button) } if(drawMode == DrawPoints) { - pointQueue.push(new ui::Point(c->PointTranslate(ui::Point(x, y)))); + pointQueue.push(ui::Point(c->PointTranslate(ui::Point(x, y)))); } } } @@ -1050,7 +1050,7 @@ void GameView::OnMouseUp(int x, int y, unsigned button) if(drawMode == DrawPoints) { c->ToolClick(toolIndex, c->PointTranslate(ui::Point(x, y))); - //pointQueue.push(new ui::Point(x, y)); + //pointQueue.push(ui::Point(x, y)); } if(drawModeReset) { @@ -1117,7 +1117,7 @@ void GameView::OnMouseWheel(int x, int y, int d) c->AdjustBrushSize(d, false, shiftBehaviour, ctrlBehaviour); if(isMouseDown) { - pointQueue.push(new ui::Point(c->PointTranslate(ui::Point(x, y)))); + pointQueue.push(ui::Point(c->PointTranslate(ui::Point(x, y)))); } } } @@ -1405,7 +1405,7 @@ void GameView::OnTick(float dt) { if(isMouseDown) { - pointQueue.push(new ui::Point(c->PointTranslate(currentMouse))); + pointQueue.push(ui::Point(c->PointTranslate(currentMouse))); } if(!pointQueue.empty()) { diff --git a/src/game/GameView.h b/src/game/GameView.h index 7fb5794ea..7c77dc0ee 100644 --- a/src/game/GameView.h +++ b/src/game/GameView.h @@ -62,7 +62,7 @@ private: std::string infoTip; int toolTipPresence; - queue pointQueue; +queue pointQueue; GameController * c; Renderer * ren; Brush * activeBrush;