[Orxonox-commit 5883] r10543 - in code/branches/core7/src/libraries/core: . object

landauf at orxonox.net landauf at orxonox.net
Sun Jun 7 14:50:04 CEST 2015


Author: landauf
Date: 2015-06-07 14:50:04 +0200 (Sun, 07 Jun 2015)
New Revision: 10543

Modified:
   code/branches/core7/src/libraries/core/Core.cc
   code/branches/core7/src/libraries/core/object/Context.cc
Log:
create and destroy root-context in a controlled manner

Modified: code/branches/core7/src/libraries/core/Core.cc
===================================================================
--- code/branches/core7/src/libraries/core/Core.cc	2015-06-07 12:16:55 UTC (rev 10542)
+++ code/branches/core7/src/libraries/core/Core.cc	2015-06-07 12:50:04 UTC (rev 10543)
@@ -122,11 +122,12 @@
         // Create a new dynamic library manager
         this->dynLibManager_ = new DynLibManager();
 
-        // TODO: initialize Root-Context
+        // create handler for static initialization
         new StaticInitializationManager(); // create singleton
         this->staticInitHandler_ = new CoreStaticInitializationHandler();
         StaticInitializationManager::getInstance().addHandler(this->staticInitHandler_);
 
+        // load root module (all libraries which are linked to the executable, including core, network, and orxonox)
         this->rootModule_ = ModuleInstance::getCurrentModuleInstance();
         StaticInitializationManager::getInstance().loadModule(this->rootModule_);
 
@@ -170,6 +171,9 @@
         orxout(internal_info) << "Loading language:" << endl;
         this->languageInstance_ = new Language();
 
+        // initialize root context
+        Context::setRootContext(new Context(NULL));
+
         // Do this soon after the ConfigFileManager has been created to open up the
         // possibility to configure everything below here
         orxout(internal_info) << "configuring Core" << endl;
@@ -250,6 +254,7 @@
         }
         if (this->staticInitHandler_)
             StaticInitializationManager::getInstance().removeHandler(this->staticInitHandler_);
+        delete Context::getRootContext();
         Context::setRootContext(NULL);
         safeObjectDelete(&rootModule_);
         safeObjectDelete(&staticInitHandler_);

Modified: code/branches/core7/src/libraries/core/object/Context.cc
===================================================================
--- code/branches/core7/src/libraries/core/object/Context.cc	2015-06-07 12:16:55 UTC (rev 10542)
+++ code/branches/core7/src/libraries/core/object/Context.cc	2015-06-07 12:50:04 UTC (rev 10543)
@@ -75,15 +75,12 @@
 
     /*static*/ void Context::setRootContext(Context* context)
     {
-        if (Context::rootContext_s)
-            delete Context::rootContext_s;
         Context::rootContext_s = context;
     }
 
     /*static*/ Context* Context::getRootContext()
     {
-        if (!Context::rootContext_s)
-            Context::rootContext_s = new Context(NULL);
+        OrxVerify(Context::rootContext_s != NULL, "Root Context is undefined");
         return Context::rootContext_s;
     }
 




More information about the Orxonox-commit mailing list