From 6040ccd27e1f4af568c2ab335be8b240d48e3761 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Thu, 9 Feb 2017 23:08:44 -0500 Subject: [PATCH] ugly fix for two empty snapshots being created on startup --- src/gui/game/GameController.cpp | 6 ++++++ src/gui/game/GameModel.cpp | 1 + src/gui/game/GameModel.h | 3 +++ 3 files changed, 10 insertions(+) diff --git a/src/gui/game/GameController.cpp b/src/gui/game/GameController.cpp index 3e6fa136f..25ec67582 100644 --- a/src/gui/game/GameController.cpp +++ b/src/gui/game/GameController.cpp @@ -144,6 +144,7 @@ GameController::GameController(): gameView->AttachController(this); gameModel->AddObserver(gameView); + gameModel->SetAllowHistory(); gameView->SetDebugHUD(Client::Ref().GetPrefBool("Renderer.DebugMode", false)); @@ -250,6 +251,11 @@ void GameController::HistoryRestore() void GameController::HistorySnapshot() { + // callbacks during initialization create two empty snapshots on startup + // Prevent that from happening here + if (!gameModel->GetAllowHistory()) + return; + std::deque history = gameModel->GetHistory(); unsigned int historyPosition = gameModel->GetHistoryPosition(); Snapshot * newSnap = gameModel->GetSimulation()->CreateSnapshot(); diff --git a/src/gui/game/GameModel.cpp b/src/gui/game/GameModel.cpp index a8d5cf57e..a9c3f944b 100644 --- a/src/gui/game/GameModel.cpp +++ b/src/gui/game/GameModel.cpp @@ -28,6 +28,7 @@ GameModel::GameModel(): currentFile(NULL), currentUser(0, ""), toolStrength(1.0f), + allowHistory(false), redoHistory(NULL), historyPosition(0), activeColourPreset(0), diff --git a/src/gui/game/GameModel.h b/src/gui/game/GameModel.h index 3727d8172..cb1eca237 100644 --- a/src/gui/game/GameModel.h +++ b/src/gui/game/GameModel.h @@ -64,6 +64,7 @@ private: Tool * regularToolset[4]; User currentUser; float toolStrength; + bool allowHistory; std::deque history; Snapshot *redoHistory; unsigned int historyPosition; @@ -131,6 +132,8 @@ public: void BuildFavoritesMenu(); void BuildQuickOptionMenu(GameController * controller); + bool GetAllowHistory() { return allowHistory; } + void SetAllowHistory() { allowHistory = true; } std::deque GetHistory(); unsigned int GetHistoryPosition(); void SetHistory(std::deque newHistory);