Skip to content

Commit 2d7ddfd

Browse files
committed
Make sure all threadpool tasks are complete upon starting or endling an activity
1 parent c618c12 commit 2d7ddfd

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Managers/ActivityMan.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,9 @@ namespace RTE {
297297
int ActivityMan::StartActivity(Activity *activity) {
298298
RTEAssert(activity, "Trying to start a null activity!");
299299

300+
g_ThreadMan.GetPriorityThreadPool().wait_for_tasks();
301+
g_ThreadMan.GetBackgroundThreadPool().wait_for_tasks();
302+
300303
// Stop all music played by the current activity. It will be re-started by the new Activity.
301304
g_AudioMan.StopMusic();
302305

@@ -442,6 +445,9 @@ namespace RTE {
442445
void ActivityMan::EndActivity() const {
443446
// TODO: Set the activity pointer to nullptr so it doesn't return junk after being destructed. Do it here, or wherever works without crashing.
444447
if (m_Activity) {
448+
g_ThreadMan.GetPriorityThreadPool().wait_for_tasks();
449+
g_ThreadMan.GetBackgroundThreadPool().wait_for_tasks();
450+
445451
m_Activity->End();
446452
g_ConsoleMan.PrintString("SYSTEM: Activity \"" + m_Activity->GetPresetName() + "\" was ended");
447453
} else {

0 commit comments

Comments
 (0)