diff --git a/src/d_main.cpp b/src/d_main.cpp index 2d10fa3dd..c68af4121 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -1973,8 +1973,6 @@ static void D_DoomInit() M_FindResponseFile (); atterm(FinalGC); - PClass::StaticInit(); - PType::StaticInit(); // Combine different file parameters with their pre-switch bits. Args->CollectFiles("-deh", ".deh"); @@ -2261,7 +2259,8 @@ void D_DoomMain (void) do { - InitGlobalSymbols(); + PClass::StaticInit(); + PType::StaticInit(); if (restart) { @@ -2637,6 +2636,8 @@ void D_DoomMain (void) S_Shutdown(); // free all channels and delete playlist C_ClearAliases(); // CCMDs won't be reinitialized so these need to be deleted here DestroyCVarsFlagged(CVAR_MOD); // Delete any cvar left by mods + ReleaseGlobalSymbols(); + PClass::StaticShutdown(); GC::FullGC(); // perform one final garbage collection before deleting the class data restart++; diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp index d930256f6..1786eab77 100644 --- a/src/dobjtype.cpp +++ b/src/dobjtype.cpp @@ -472,8 +472,17 @@ void PType::GetTypeIDs(intptr_t &id1, intptr_t &id2) const // //========================================================================== +void ReleaseGlobalSymbols() +{ + TypeTable.Clear(); + GlobalSymbols.ReleaseSymbols(); +} + void PType::StaticInit() { + // Add types to the global symbol table. + atterm(ReleaseGlobalSymbols); + // Set up TypeTable hash keys. RUNTIME_CLASS(PErrorType)->TypeTableType = RUNTIME_CLASS(PErrorType); RUNTIME_CLASS(PVoidType)->TypeTableType = RUNTIME_CLASS(PVoidType); @@ -517,18 +526,7 @@ void PType::StaticInit() TypeTable.AddType(TypeState = new PStatePointer); TypeTable.AddType(TypeFixed = new PFixed); TypeTable.AddType(TypeAngle = new PAngle); -} -void ReleaseGlobalSymbols() -{ - GlobalSymbols.ReleaseSymbols(); -} - -void InitGlobalSymbols() -{ - // Add types to the global symbol table. - atterm(ReleaseGlobalSymbols); - GlobalSymbols.ReleaseSymbols(); GlobalSymbols.AddSymbol(new PSymbolType(NAME_sByte, TypeSInt8)); GlobalSymbols.AddSymbol(new PSymbolType(NAME_Byte, TypeUInt8)); GlobalSymbols.AddSymbol(new PSymbolType(NAME_Short, TypeSInt16)); @@ -2061,6 +2059,17 @@ void PClass::StaticShutdown () } TypeTable.Clear(); bShutdown = true; + + AllClasses.Clear(); + PClassActor::AllActorClasses.Clear(); + + FAutoSegIterator probe(CRegHead, CRegTail); + + while (*++probe != NULL) + { + ((ClassReg *)*probe)->MyClass = NULL; + } + } //========================================================================== diff --git a/src/dobjtype.h b/src/dobjtype.h index ff34a4b8f..313130ddb 100644 --- a/src/dobjtype.h +++ b/src/dobjtype.h @@ -801,6 +801,6 @@ public: PSymbolConstString() {} }; -void InitGlobalSymbols(); +void ReleaseGlobalSymbols(); #endif diff --git a/src/fragglescript/t_script.cpp b/src/fragglescript/t_script.cpp index 98911a418..5f62fe6ac 100644 --- a/src/fragglescript/t_script.cpp +++ b/src/fragglescript/t_script.cpp @@ -170,6 +170,7 @@ DFsScript::DFsScript() void DFsScript::Destroy() { + if (this == global_script) global_script = NULL; ClearVariables(true); ClearSections(); ClearChildren();