From 03b45f44dfdb86a9607aaa09a02e5c57968e275f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 22 Jul 2016 13:28:32 -0400 Subject: TITANIC: Workaround for original using destroyed objects after save load The original loads savegames by loading a new project hierarchy and then deleting and replacing the existing one. This means that objects in the original project, such as the PET control, are destroyed, leaving the remainder of the PET code that called load operating on destroyed objects. This workaround instead flags for a load to be done, and adds new code in the game manager to take care of it. This way, the remainder of the PET event handling can finish first, and it will be then safe to destroy the original game project (including PET) and load the new savegame. --- engines/titanic/pet_control/pet_load.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'engines/titanic/pet_control/pet_load.cpp') diff --git a/engines/titanic/pet_control/pet_load.cpp b/engines/titanic/pet_control/pet_load.cpp index cb3514ee56..04eec54f25 100644 --- a/engines/titanic/pet_control/pet_load.cpp +++ b/engines/titanic/pet_control/pet_load.cpp @@ -24,6 +24,7 @@ #include "titanic/pet_control/pet_control.h" #include "titanic/core/project_item.h" #include "titanic/game_manager.h" +#include "titanic/titanic.h" namespace Titanic { @@ -57,16 +58,10 @@ void CPetLoad::execute() { CPetControl *pet = getPetControl(); if (_savegameSlotNum >= 0 && _slotInUse[_savegameSlotNum]) { - CProjectItem *project = pet ? pet->getRoot() : nullptr; - CGameManager *gameManager = project ? project->getGameManager() : nullptr; + CMainGameWindow *window = g_vm->_window; - if (project && gameManager) { - pet->displayMessage("Loading the selected game, please wait."); - - gameManager->destroyTreeItem(); - gameManager->initBounds(); - project->loadGame(_savegameSlotNum); - } + // WORKAROUND: Schedule the savegame to be loaded after frame rendering ends + window->loadGame(_savegameSlotNum); } else if (pet) { pet->displayMessage("You must select a game to load first."); } -- cgit v1.2.3