From ee93dc3b571ea3a2e1412ed964c6ecd05be8f57c Mon Sep 17 00:00:00 2001 From: Lukas Aldershaab Date: Sun, 8 Oct 2023 19:43:31 +0200 Subject: [PATCH] Ensure that getGlobalScope always returns the same object --- Engine/source/console/engineExports.cpp | 2 -- Engine/source/console/engineExports.h | 10 ++++++---- Engine/source/console/engineTypes.cpp | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Engine/source/console/engineExports.cpp b/Engine/source/console/engineExports.cpp index ef8ca7bca..d43c909cc 100644 --- a/Engine/source/console/engineExports.cpp +++ b/Engine/source/console/engineExports.cpp @@ -34,8 +34,6 @@ END_IMPLEMENT_CLASS; IMPLEMENT_NONINSTANTIABLE_CLASS( EngineExportScope, "A scope contained a collection of exported engine API entities." ) END_IMPLEMENT_CLASS; - -EngineExportScope EngineExportScope::smGlobalScope; //----------------------------------------------------------------------------- diff --git a/Engine/source/console/engineExports.h b/Engine/source/console/engineExports.h index b40c4bdc9..8f01a5f93 100644 --- a/Engine/source/console/engineExports.h +++ b/Engine/source/console/engineExports.h @@ -142,9 +142,6 @@ class EngineExportScope : public EngineExport /// Head of the link chain of exports for this scope. EngineExport* mExports; - - /// The global export scope singleton. - static EngineExportScope smGlobalScope; public: @@ -158,7 +155,12 @@ class EngineExportScope : public EngineExport /// Return the global export scope singleton. This is the root of the /// export hierarchy and thus directly or indirectly contains all /// entities exported by the engine. - static EngineExportScope* getGlobalScope() { return &smGlobalScope; } + static EngineExportScope* getGlobalScope() + { + /// The global export scope singleton. + static EngineExportScope sGlobalScope; + return &sGlobalScope; + } /// Return the chain of exports associated with this scope. EngineExport* getExports() const { return mExports; } diff --git a/Engine/source/console/engineTypes.cpp b/Engine/source/console/engineTypes.cpp index cb5626d3a..6efa5409e 100644 --- a/Engine/source/console/engineTypes.cpp +++ b/Engine/source/console/engineTypes.cpp @@ -26,5 +26,5 @@ const EngineTypeInfo* const _EngineTypeTraits< void >::TYPEINFO = NULL; EngineExportScope& _GLOBALSCOPE::__engineExportScope() { - return EngineExportScope::smGlobalScope; + return *EngineExportScope::getGlobalScope(); }