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.
This commit is contained in:
Tamás Bálint Misius 2023-09-10 11:32:32 +02:00
parent 28d86d2859
commit d2d1fd902f
No known key found for this signature in database
GPG Key ID: 5B472A12F6ECA9F2
2 changed files with 2 additions and 2 deletions

View File

@ -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()

View File

@ -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();
}