Pause renderer thread when needed in GameModel

This commit is contained in:
Tamás Bálint Misius 2024-09-15 18:25:16 +02:00
parent 12322bb382
commit c842086309
No known key found for this signature in database
GPG Key ID: 5B472A12F6ECA9F2
2 changed files with 4 additions and 1 deletions

View File

@ -192,6 +192,7 @@ GameModel::~GameModel()
prefs.Set("Decoration.Alpha", (int)colour.Alpha);
}
view->PauseRendererThread();
delete sim;
delete ren;
//if(activeTools)
@ -760,6 +761,7 @@ void GameModel::SetSave(std::unique_ptr<SaveInfo> newSave, bool invertIncludePre
auto *saveData = currentSave->GetGameSave();
SaveToSimParameters(*saveData);
sim->clear_sim();
view->PauseRendererThread();
ren->ClearAccumulation();
sim->Load(saveData, !invertIncludePressure, { 0, 0 });
// This save was created before logging existed
@ -811,6 +813,7 @@ void GameModel::SetSaveFile(std::unique_ptr<SaveFile> newSave, bool invertInclud
auto *saveData = currentFile->GetGameSave();
SaveToSimParameters(*saveData);
sim->clear_sim();
view->PauseRendererThread();
ren->ClearAccumulation();
sim->Load(saveData, !invertIncludePressure, { 0, 0 });
Client::Ref().OverwriteAuthorInfo(saveData->authors);

View File

@ -267,7 +267,7 @@ public:
{
return *rendererFrame;
}
// Call this before accessing Renderer "out of turn", e.g. from RenderView. This *does not*
// Call this before accessing Renderer "out of turn", e.g. from RenderView or GameModel. This *does not*
// include OptionsModel or Lua setting functions because they only access the RendererSettings
// in GameModel, or Lua drawing functions because they only access Renderer in eventTraitSimGraphics
// and *SimDraw events, and the renderer thread gets paused anyway if there are handlers