[Orxonox-commit 5920] r10579 - code/branches/core7/src/orxonox

landauf at orxonox.net landauf at orxonox.net
Wed Sep 9 16:14:15 CEST 2015


Author: landauf
Date: 2015-09-09 16:14:14 +0200 (Wed, 09 Sep 2015)
New Revision: 10579

Modified:
   code/branches/core7/src/orxonox/Level.cc
Log:
inverted dependency between level and gametype: gametype now references level with a strong-pointer, but level references gametype with a weak-pointer. this means that gametype can be destroyed before level which in turn means that level is the last instance that is destroyed when the level is unloaded.

Modified: code/branches/core7/src/orxonox/Level.cc
===================================================================
--- code/branches/core7/src/orxonox/Level.cc	2015-09-09 14:10:21 UTC (rev 10578)
+++ code/branches/core7/src/orxonox/Level.cc	2015-09-09 14:14:14 UTC (rev 10579)
@@ -122,8 +122,9 @@
 
         Gametype* rootgametype = orxonox_cast<Gametype*>(identifier->fabricate(this));
 
-        rootgametype->setLevel(StrongPtr<Level>(NULL)); // avoid circular references
-        this->setGametype(StrongPtr<Gametype>(rootgametype));
+        // store a weak-pointer to the gametype to avoid a circular dependency between this level and the gametype (which has a strong-reference on this level)
+        this->setGametype(WeakPtr<Gametype>(rootgametype));
+
         rootgametype->init(); // call init() AFTER the gametype was set
 
         if (LevelManager::exists())




More information about the Orxonox-commit mailing list