aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicola Mettifogo2008-06-22 05:42:22 +0000
committerNicola Mettifogo2008-06-22 05:42:22 +0000
commit446f66807f078b574cb31d87bebdcff2f55953fa (patch)
treed35bf6f5cac7994775edb1ae4c618f8d77506027
parent8ce5dcc8e84cbd1e58437cebabd129760a873900 (diff)
downloadscummvm-rg350-446f66807f078b574cb31d87bebdcff2f55953fa.tar.gz
scummvm-rg350-446f66807f078b574cb31d87bebdcff2f55953fa.tar.bz2
scummvm-rg350-446f66807f078b574cb31d87bebdcff2f55953fa.zip
Circular references between Zone/Animation and Command are now manually removed, to allow the objects - which are stored into SharedPtr's - to be deallocated.
svn-id: r32744
-rw-r--r--engines/parallaction/parallaction.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp
index 25ebe4263d..4f586961a6 100644
--- a/engines/parallaction/parallaction.cpp
+++ b/engines/parallaction/parallaction.cpp
@@ -86,7 +86,7 @@ Parallaction::Parallaction(OSystem *syst, const PARALLACTIONGameDescription *gam
Parallaction::~Parallaction() {
clearSet(_commandOpcodes);
clearSet(_instructionOpcodes);
-
+
delete _debugger;
delete _globalTable;
delete _callableNames;
@@ -95,7 +95,7 @@ Parallaction::~Parallaction() {
freeCharacter();
destroyInventory();
-
+
delete _localFlagNames;
delete _gfx;
delete _soundMan;
@@ -193,6 +193,9 @@ AnimationPtr Parallaction::findAnimation(const char *name) {
}
void Parallaction::freeAnimations() {
+ for (AnimationList::iterator it = _location._animations.begin(); it != _location._animations.end(); it++) {
+ (*it)->_commands.clear(); // See comment for freeZones(), about circular references.
+ }
_location._animations.clear();
return;
}
@@ -479,6 +482,9 @@ void Parallaction::freeZones() {
debugC(2, kDebugExec, "freeZones preserving zone '%s'", z->_name);
it++;
} else {
+ (*it)->_commands.clear(); // Since commands may reference zones, and both commands and zones are kept stored into
+ // SharedPtr's, we need to kill commands explicitly to destroy any potential circular
+ // reference.
it = _location._zones.erase(it);
}
}