Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 9, 2015, 4:10:21 PM (9 years ago)
Author:
landauf
Message:

removed the 'bAddRef' argument from StrongPtr's constructor. it was a bad hack and shouldn't be used. in fact, it was only used to avoid recursive dependencies if one of the four base objects (Namespace, Level, Gametype, Scene) referenced itself with a StrongPtr.
instead of the 'bAddRef'-hack BaseObject now stores the references in a new construct called StrongOrWeakPtr which can either store the reference in a StrongPtr (like it did before) or in a WeakPtr (which is a cleaner alternative to 'bAddRef=true')

Location:
code/branches/core7/src/orxonox
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core7/src/orxonox/Level.cc

    r10576 r10578  
    4949        RegisterObject(Level);
    5050
    51         this->setLevel(StrongPtr<Level>(this, false));
     51        this->setLevel(WeakPtr<Level>(this)); // store a weak-pointer to itself (a strong-pointer would create a recursive dependency)
    5252
    5353        this->registerVariables();
     
    123123        Gametype* rootgametype = orxonox_cast<Gametype*>(identifier->fabricate(this));
    124124
    125         rootgametype->setLevel(NULL); // avoid circular references
    126         this->setGametype(rootgametype);
     125        rootgametype->setLevel(StrongPtr<Level>(NULL)); // avoid circular references
     126        this->setGametype(StrongPtr<Gametype>(rootgametype));
    127127        rootgametype->init(); // call init() AFTER the gametype was set
    128128
  • code/branches/core7/src/orxonox/Scene.cc

    r10571 r10578  
    6262        RegisterObject(Scene);
    6363
    64         this->setScene(StrongPtr<Scene>(this, false), this->getObjectID());
     64        this->setScene(WeakPtr<Scene>(this), this->getObjectID()); // store a weak-pointer to itself (a strong-pointer would create a recursive dependency)
    6565
    6666        this->bShadows_ = true;
  • code/branches/core7/src/orxonox/gametypes/Gametype.cc

    r10575 r10578  
    6161        RegisterObject(Gametype);
    6262
    63         this->setGametype(StrongPtr<Gametype>(this, false));
     63        this->setGametype(WeakPtr<Gametype>(this)); // store a weak-pointer to itself (a strong-pointer would create a recursive dependency)
    6464
    6565        this->gtinfo_ = new GametypeInfo(context);
  • code/branches/core7/src/orxonox/infos/PlayerInfo.cc

    r10576 r10578  
    9898    {
    9999        Gametype* oldGametype = this->getGametype();
    100         this->setGametype(gametype);
     100        this->setGametype(StrongPtr<Gametype>(gametype));
    101101        Gametype* newGametype = this->getGametype();
    102102
Note: See TracChangeset for help on using the changeset viewer.