From 0645a3dbde92fe4fbd46895cf24470535b7245aa Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 8 Mar 2016 18:48:26 -0500 Subject: TITANIC: Fix crash when compressed newgame.st file was closed --- engines/titanic/core/project_item.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'engines/titanic/core') diff --git a/engines/titanic/core/project_item.cpp b/engines/titanic/core/project_item.cpp index e759b87e9f..2fa65f9e33 100644 --- a/engines/titanic/core/project_item.cpp +++ b/engines/titanic/core/project_item.cpp @@ -134,18 +134,20 @@ void CProjectItem::resetGameManager() { void CProjectItem::loadGame(int slotId) { CompressedFile file; - Common::InSaveFile *saveFile = nullptr; // Clear any existing project contents clear(); // Open either an existing savegame slot or the new game template if (slotId >= 0) { - saveFile = g_system->getSavefileManager()->openForLoading( + Common::InSaveFile *saveFile = g_system->getSavefileManager()->openForLoading( Common::String::format("slot%d.gam", slotId)); file.open(saveFile); } else { - file.open("newgame.st"); + Common::File *newFile = new Common::File(); + if (!newFile->open("newgame.st")) + error("Could not open newgame.st"); + file.open(newFile); } // Load the contents in @@ -165,6 +167,7 @@ void CProjectItem::loadGame(int slotId) { item->detach(); item->addUnder(this); } + // Loaded project instance is no longer needed newProject->destroyAll(); -- cgit v1.2.3