From d2d1fd902fbc513813ac3aa7fd42ccd1c3299640 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20B=C3=A1lint=20Misius?= Date: Sun, 10 Sep 2023 11:32:32 +0200 Subject: [PATCH] Fix crash upon changing tpt.brushID This was because brushes are not in an initialized state by default, SetRadius needs to be called on them before they can be used. This is ensured elsewhere but had not been ensured on this code path. This is hilariously bad design and needs to be fixed sometime. --- src/gui/game/GameController.cpp | 2 -- src/gui/game/GameModel.cpp | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/game/GameController.cpp b/src/gui/game/GameController.cpp index 5cf2f4d08..b0c9e23f4 100644 --- a/src/gui/game/GameController.cpp +++ b/src/gui/game/GameController.cpp @@ -1455,9 +1455,7 @@ void GameController::Vote(int direction) void GameController::ChangeBrush() { - auto prev_size = gameModel->GetBrush().GetRadius(); gameModel->SetBrushID(gameModel->GetBrushID()+1); - gameModel->GetBrush().SetRadius(prev_size); } void GameController::ClearSim() diff --git a/src/gui/game/GameModel.cpp b/src/gui/game/GameModel.cpp index 6a6b86bfd..3c0e3c0ae 100644 --- a/src/gui/game/GameModel.cpp +++ b/src/gui/game/GameModel.cpp @@ -832,7 +832,9 @@ int GameModel::GetBrushID() void GameModel::SetBrushID(int i) { + auto prevRadius = brushList[currentBrush]->GetRadius(); currentBrush = i%brushList.size(); + brushList[currentBrush]->SetRadius(prevRadius); notifyBrushChanged(); }