Clear Services Map during VM Shutdown

This commit is contained in:
Ricardo Luís Vaz Silva 2023-06-28 14:28:07 -03:00 committed by Christoph Oelckers
parent a8b8de94d6
commit 71d4eb66f2
2 changed files with 10 additions and 2 deletions

View file

@ -231,6 +231,8 @@ void PClass::StaticInit ()
// //
//========================================================================== //==========================================================================
void ClearServices();
void PClass::StaticShutdown () void PClass::StaticShutdown ()
{ {
if (WP_NOCHANGE != nullptr) if (WP_NOCHANGE != nullptr)
@ -238,6 +240,7 @@ void PClass::StaticShutdown ()
delete WP_NOCHANGE; delete WP_NOCHANGE;
} }
ClearServices();
// delete all variables containing pointers to script functions. // delete all variables containing pointers to script functions.
for (auto p : FunctionPtrList) for (auto p : FunctionPtrList)
{ {

View file

@ -57,8 +57,8 @@
static ZSMap<FName, DObject*> AllServices; static ZSMap<FName, DObject*> AllServices;
static void MarkServices() { static void MarkServices()
{
ZSMap<FName, DObject*>::Iterator it(AllServices); ZSMap<FName, DObject*>::Iterator it(AllServices);
ZSMap<FName, DObject*>::Pair* pair; ZSMap<FName, DObject*>::Pair* pair;
while (it.NextPair(pair)) while (it.NextPair(pair))
@ -82,6 +82,11 @@ void InitServices()
GC::AddMarkerFunc(&MarkServices); GC::AddMarkerFunc(&MarkServices);
} }
void ClearServices()
{
AllServices.Clear();
}
//========================================================================== //==========================================================================