Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 14, 2013, 6:42:28 PM (11 years ago)
Author:
landauf
Message:

added ability to set the root-context explicitly (and also to destroy it before the class-hierarchy is destroyed).
currently it's not possible to set the root context explicitly during startup of the game because it is already used by static initialization

Location:
code/branches/core6/src/libraries/core/object
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core6/src/libraries/core/object/Context.cc

    r9629 r9649  
    3737namespace orxonox
    3838{
     39    Context* Context::rootContext_s = 0;
     40
    3941    Context::Context(Context* context) : Listable(this), parentContext_(context)
    4042    {
     
    5456    }
    5557
     58    /*static*/ void Context::setRootContext(Context* context)
     59    {
     60        if (Context::rootContext_s)
     61            delete Context::rootContext_s;
     62        Context::rootContext_s = context;
     63    }
     64
    5665    /*static*/ Context* Context::getRootContext()
    5766    {
    58         static Context rootContext(NULL);
    59         return &rootContext;
     67        if (!Context::rootContext_s)
     68            Context::rootContext_s = new Context(NULL);
     69        return Context::rootContext_s;
    6070    }
    6171
  • code/branches/core6/src/libraries/core/object/Context.h

    r9629 r9649  
    4646    {
    4747        public:
     48            static void setRootContext(Context* context);
    4849            static Context* getRootContext();
    4950
     
    7273            Context* parentContext_;
    7374            std::vector<ObjectListBase*> objectLists_;
     75
     76            static Context* rootContext_s;
    7477    };
    7578}
Note: See TracChangeset for help on using the changeset viewer.