From 407d38f3d6df2cbbf399ce305033766d099cf94a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 28 Apr 2015 21:54:30 +0200 Subject: [PATCH] - add a bit more stuff that needs to be done before a restart to ensure that all obsolete data is taken down. (There's still a problem with the garbage collector kicking in and deleting stuff it's not supposed to, so Restart still doesn't work) --- src/d_main.cpp | 19 +++++++++++++++++++ src/dobject.h | 4 ++++ 2 files changed, 23 insertions(+) diff --git a/src/d_main.cpp b/src/d_main.cpp index c68af41216..2107763e7c 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -107,6 +107,8 @@ #include "resourcefiles/resourcefile.h" #include "r_renderer.h" #include "p_local.h" +#include "autosegs.h" +#include "fragglescript/t_fs.h" EXTERN_CVAR(Bool, hud_althud) void DrawHUD(); @@ -2636,10 +2638,27 @@ 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 + + GC::FullGC(); // clean up before taking down the object list. + + // Delete the VM functions here. The garbage collector will not do this automatically because they are referenced from the global action function definitions. + FAutoSegIterator probe(ARegHead, ARegTail); + while (*++probe != NULL) + { + AFuncDesc *afunc = (AFuncDesc *)*probe; + *(afunc->VMPointer) = NULL; + } + ReleaseGlobalSymbols(); PClass::StaticShutdown(); GC::FullGC(); // perform one final garbage collection before deleting the class data + + for (DObject *obj = GC::Root; obj; obj = obj->ObjNext) + { + obj->ClearClass(); // Delete the Class pointer because the data it points to has been deleted. This will automatically be reset if needed. + } + restart++; } } diff --git a/src/dobject.h b/src/dobject.h index 40445c8a03..4b6f1ec49f 100644 --- a/src/dobject.h +++ b/src/dobject.h @@ -462,6 +462,10 @@ public: void SerializeUserVars(FArchive &arc); virtual void Serialize (FArchive &arc); + void ClearClass() + { + Class = NULL; + } // For catching Serialize functions in derived classes // that don't call their base class.