mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-10 03:40:25 +00:00
BURIED: Clean up new scene on death to prevent memory leaks
This plugs memory leak in this case
This commit is contained in:
parent
fe493acf55
commit
b90a049ba0
@ -361,8 +361,12 @@ bool SceneViewWindow::jumpToScene(const Location &newLocation) {
|
||||
|
||||
SceneBase *newScene = constructSceneObject(this, newSceneStaticData, passedLocation);
|
||||
|
||||
if (_currentScene && _currentScene->postExitRoom(this, passedLocation) == SC_DEATH)
|
||||
if (_currentScene && _currentScene->postExitRoom(this, passedLocation) == SC_DEATH) {
|
||||
newScene->preDestructor();
|
||||
delete newScene;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!newScene)
|
||||
error("Failed to create scene");
|
||||
@ -608,8 +612,11 @@ bool SceneViewWindow::moveToDestination(const DestinationScene &destinationData)
|
||||
// Call the post-exit function
|
||||
retVal = _currentScene->postExitRoom(this, destinationData.destinationScene);
|
||||
|
||||
if (retVal == SC_DEATH)
|
||||
if (retVal == SC_DEATH) {
|
||||
newScene->preDestructor();
|
||||
delete newScene;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (retVal != SC_TRUE) {
|
||||
newScene->preDestructor();
|
||||
@ -814,8 +821,12 @@ bool SceneViewWindow::timeSuitJump(int destination) {
|
||||
|
||||
if (_currentScene) {
|
||||
// Post-transition function
|
||||
if (_currentScene->postExitRoom(this, specOldLocation) == SC_DEATH)
|
||||
if (_currentScene->postExitRoom(this, specOldLocation) == SC_DEATH) {
|
||||
newScene->preDestructor();
|
||||
delete newScene;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Delete the old scene
|
||||
_currentScene->preDestructor();
|
||||
|
Loading…
Reference in New Issue
Block a user