Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 5337b51

Browse files
committed
Purge all MOs before destroying the current Scene in SceneMan::LoadScene to fix crash where AudioMan would try to get Scene dimensions of a scene that was already destroyed when starting a new Activity while sound emitting MOs were still present on Scene
1 parent 85aca10 commit 5337b51

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

Managers/SceneMan.cpp

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -170,22 +170,18 @@ Material * SceneMan::AddMaterialCopy(Material *mat)
170170
// Description: Actually loads a new Scene into memory. has to be done before using
171171
// this object.
172172

173-
int SceneMan::LoadScene(Scene *pNewScene, bool placeObjects, bool placeUnits)
174-
{
175-
if (!pNewScene)
176-
return -1;
173+
int SceneMan::LoadScene(Scene *pNewScene, bool placeObjects, bool placeUnits) {
174+
if (!pNewScene) {
175+
return -1;
176+
}
177177

178-
// Unload and destroy any scene we might have loaded already
179-
if (m_pCurrentScene)
180-
{
181-
delete m_pCurrentScene;
182-
m_pCurrentScene = 0;
183-
}
178+
g_MovableMan.PurgeAllMOs();
179+
g_PostProcessMan.ClearScenePostEffects();
184180

185-
// Clear out all the MO's in the scene
186-
g_MovableMan.PurgeAllMOs();
187-
// Clear the post effects
188-
g_PostProcessMan.ClearScenePostEffects();
181+
if (m_pCurrentScene) {
182+
delete m_pCurrentScene;
183+
m_pCurrentScene = nullptr;
184+
}
189185

190186
g_NetworkServer.LockScene(true);
191187

0 commit comments

Comments
 (0)