aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2016-11-15 21:04:30 -0500
committerPaul Gilbert2016-11-15 21:04:30 -0500
commitafb4b6227a0f20ca829801e00dcf75eeb4c18999 (patch)
treebcff5fd2dd3d955f7dc4e1759f299b3c1c62d9d3
parent5971e0302f331dd05cdedc7ab4a9762cb947b02f (diff)
downloadscummvm-rg350-afb4b6227a0f20ca829801e00dcf75eeb4c18999.tar.gz
scummvm-rg350-afb4b6227a0f20ca829801e00dcf75eeb4c18999.tar.bz2
scummvm-rg350-afb4b6227a0f20ca829801e00dcf75eeb4c18999.zip
TITANIC: Fixes for freeing project and engine objects on exit
-rw-r--r--engines/titanic/core/project_item.h1
-rw-r--r--engines/titanic/main_game_window.cpp1
-rw-r--r--engines/titanic/support/movie.cpp12
-rw-r--r--engines/titanic/titanic.cpp17
4 files changed, 14 insertions, 17 deletions
diff --git a/engines/titanic/core/project_item.h b/engines/titanic/core/project_item.h
index 20c4a4377a..14ca3fd229 100644
--- a/engines/titanic/core/project_item.h
+++ b/engines/titanic/core/project_item.h
@@ -152,6 +152,7 @@ public:
public:
CLASSDEF;
CProjectItem();
+ virtual ~CProjectItem() { destroyChildren(); }
/**
* Save the data for the class to file
diff --git a/engines/titanic/main_game_window.cpp b/engines/titanic/main_game_window.cpp
index de0ac715ba..102458969e 100644
--- a/engines/titanic/main_game_window.cpp
+++ b/engines/titanic/main_game_window.cpp
@@ -46,6 +46,7 @@ CMainGameWindow::CMainGameWindow(TitanicEngine *vm): _vm(vm),
}
CMainGameWindow::~CMainGameWindow() {
+ delete _project;
}
void CMainGameWindow::applicationStarting() {
diff --git a/engines/titanic/support/movie.cpp b/engines/titanic/support/movie.cpp
index 1bdcdee6da..c26e4eb3c4 100644
--- a/engines/titanic/support/movie.cpp
+++ b/engines/titanic/support/movie.cpp
@@ -50,15 +50,9 @@ void CMovie::init() {
}
void CMovie::deinit() {
- // Delete each movie in turn
- for (CMovieList::iterator i = _playingMovies->begin(); i != _playingMovies->end(); ) {
- // We need to increment iterator before deleting movie,
- // since the CMovie destructor calls removeFromPlayingMovies
- CMovie *movie = *i;
- ++i;
- delete movie;
- }
-
+ // At this point, there shouldn't be any playing movies left,
+ // since their owning objects should have freed them
+ assert(_playingMovies->empty());
delete _playingMovies;
delete _movieSurface;
}
diff --git a/engines/titanic/titanic.cpp b/engines/titanic/titanic.cpp
index c6fb0a17e3..e80dc54bcb 100644
--- a/engines/titanic/titanic.cpp
+++ b/engines/titanic/titanic.cpp
@@ -69,13 +69,6 @@ TitanicEngine::TitanicEngine(OSystem *syst, const TitanicGameDescription *gameDe
}
TitanicEngine::~TitanicEngine() {
- delete _debugger;
- delete _events;
- delete _window;
- delete _screenManager;
- delete _filesManager;
- delete _screen;
- CSaveableObject::freeClassList();
}
void TitanicEngine::initializePath(const Common::FSNode &gamePath) {
@@ -116,10 +109,16 @@ void TitanicEngine::initialize() {
}
void TitanicEngine::deinitialize() {
+ delete _debugger;
+ delete _events;
+ delete _window;
+ delete _screenManager;
+ delete _filesManager;
+ delete _screen;
+
CEnterExitFirstClassState::deinit();
CGetLiftEye2::deinit();
CHose::deinit();
- CMovie::deinit();
CSGTNavigation::deinit();
CSGTStateRoom::deinit();
CExitPellerator::deinit();
@@ -127,6 +126,8 @@ void TitanicEngine::deinitialize() {
CGameObject::deinit();
CTelevision::deinit();
TTnpcScript::deinit();
+ CMovie::deinit();
+ CSaveableObject::freeClassList();
}
Common::Error TitanicEngine::run() {