Procházet zdrojové kódy

Ensure that getGlobalScope always returns the same object

Lukas Aldershaab před 1 rokem
rodič
revize
ee93dc3b57

+ 0 - 2
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;
 
 
 //-----------------------------------------------------------------------------

+ 6 - 4
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; }

+ 1 - 1
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();
 }