From d014395daea89ccbaf91809010e691fee6a0b6e8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 14 Apr 2017 19:40:50 +0200 Subject: [PATCH] - do not delete the namespaces when removing compiler symbols. They still get referenced by some types and must remain until the engine shuts down. --- src/dobjtype.cpp | 2 +- src/scripting/symbols.cpp | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp index 2bd1a8a0f..bf41d3cde 100644 --- a/src/dobjtype.cpp +++ b/src/dobjtype.cpp @@ -267,6 +267,7 @@ void PClass::StaticShutdown () { p.PendingWeapon = nullptr; } + Namespaces.ReleaseSymbols(); // This must be done in two steps because the native classes are not ordered by inheritance, // so all meta data must be gone before deleting the actual class objects. @@ -275,7 +276,6 @@ void PClass::StaticShutdown () // Unless something went wrong, anything left here should be class and type objects only, which do not own any scripts. bShutdown = true; TypeTable.Clear(); - Namespaces.ReleaseSymbols(); ClassDataAllocator.FreeAllBlocks(); AllClasses.Clear(); PClassActor::AllActorClasses.Clear(); diff --git a/src/scripting/symbols.cpp b/src/scripting/symbols.cpp index 76afe8d2a..9fcefd603 100644 --- a/src/scripting/symbols.cpp +++ b/src/scripting/symbols.cpp @@ -512,13 +512,16 @@ PNamespace *FNamespaceManager::NewNamespace(int filenum) //========================================================================== // -// +// Deallocate the entire namespace manager. // //========================================================================== void FNamespaceManager::ReleaseSymbols() { - RemoveSymbols(); + for (auto ns : AllNamespaces) + { + delete ns; + } GlobalNamespace = nullptr; AllNamespaces.Clear(); } @@ -537,7 +540,7 @@ int FNamespaceManager::RemoveSymbols() for (auto ns : AllNamespaces) { count += ns->Symbols.Symbols.CountUsed(); - delete ns; + ns->Symbols.ReleaseSymbols(); } return count; } @@ -550,7 +553,6 @@ int FNamespaceManager::RemoveSymbols() void RemoveUnusedSymbols() { - // Global symbols are not needed anymore after running the compiler. int count = Namespaces.RemoveSymbols(); // We do not need any non-field and non-function symbols in structs and classes anymore.