Fix unloading scenarios with Map.c or System.ocg scripts (#1778)

Destruction order matters!
qteditor
Nicolas Hake 2016-07-07 14:39:18 +02:00
parent 4725043493
commit dcd8d9676a
4 changed files with 9 additions and 2 deletions

View File

@ -578,6 +578,7 @@ void C4Game::Clear()
// Clear the particles before cleaning up the objects.
Particles.Clear();
DeleteObjects(true);
::MapScript.Clear();
::Definitions.Clear();
Landscape.Clear();
PXS.Clear();
@ -589,7 +590,6 @@ void C4Game::Clear()
Info.Clear();
Title.Clear();
pScenarioObjectsScript = NULL;
::MapScript.Clear();
::GameScript.Clear();
Names.Clear();
GameText.Clear();

View File

@ -703,9 +703,9 @@ bool C4MapScriptHost::LoadData(const char * f, const char * d, C4LangStringTable
void C4MapScriptHost::Clear()
{
C4ScriptHost::Clear();
delete LayerPrototype; delete MapPrototype;
LayerPrototype = MapPrototype = NULL;
C4ScriptHost::Clear();
}
C4PropListStatic * C4MapScriptHost::GetPropList()

View File

@ -229,8 +229,14 @@ C4ExtraScriptHost::C4ExtraScriptHost(C4String *parent_key_name):
{
}
C4ExtraScriptHost::~C4ExtraScriptHost()
{
Clear();
}
void C4ExtraScriptHost::Clear()
{
C4ScriptHost::Clear();
ParserPropList._getPropList()->Clear();
}

View File

@ -100,6 +100,7 @@ class C4ExtraScriptHost: public C4ScriptHost
C4Value ParserPropList;
public:
C4ExtraScriptHost(C4String *parent_key_name = NULL);
~C4ExtraScriptHost();
void Clear();
bool Delete() { return true; }