Skip to content

Commit f24a647

Browse files
committed
Wait on threadpools when saving/loading
1 parent 9392f2c commit f24a647

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Source/Managers/ActivityMan.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ bool ActivityMan::SaveCurrentGame(const std::string& fileName) {
7676
m_SaveGameTask.wait();
7777
m_SaveGameTask = BS::multi_future<void>();
7878

79+
// Might not be strictly necessary?
80+
g_ThreadMan.GetPriorityThreadPool().wait_for_tasks();
81+
g_ThreadMan.GetBackgroundThreadPool().wait_for_tasks();
82+
7983
Scene* scene = g_SceneMan.GetScene();
8084
GAScripted* activity = dynamic_cast<GAScripted*>(GetActivity());
8185

@@ -151,6 +155,9 @@ bool ActivityMan::SaveCurrentGame(const std::string& fileName) {
151155
bool ActivityMan::LoadAndLaunchGame(const std::string& fileName) {
152156
m_SaveGameTask.wait();
153157

158+
g_ThreadMan.GetPriorityThreadPool().wait_for_tasks();
159+
g_ThreadMan.GetBackgroundThreadPool().wait_for_tasks();
160+
154161
std::string saveFilePath = g_PresetMan.GetFullModulePath(c_UserScriptedSavesModuleName) + "/" + fileName + "/Save.ini";
155162

156163
if (!std::filesystem::exists(saveFilePath)) {

0 commit comments

Comments
 (0)