[Orxonox-commit 5895] r10554 - code/branches/core7/src/orxonox/gametypes
landauf at orxonox.net
landauf at orxonox.net
Sat Aug 29 16:23:00 CEST 2015
Author: landauf
Date: 2015-08-29 16:23:00 +0200 (Sat, 29 Aug 2015)
New Revision: 10554
Modified:
code/branches/core7/src/orxonox/gametypes/Gametype.cc
code/branches/core7/src/orxonox/gametypes/Gametype.h
Log:
Gametype should store a WeakPtr to GametypeInfo to avoid circular reference if GametypeInfo references back to its Gametype
Modified: code/branches/core7/src/orxonox/gametypes/Gametype.cc
===================================================================
--- code/branches/core7/src/orxonox/gametypes/Gametype.cc 2015-08-28 20:35:51 UTC (rev 10553)
+++ code/branches/core7/src/orxonox/gametypes/Gametype.cc 2015-08-29 14:23:00 UTC (rev 10554)
@@ -60,10 +60,11 @@
{
RegisterObject(Gametype);
+ this->setGametype(SmartPtr<Gametype>(this, false));
+
this->gtinfo_ = new GametypeInfo(context);
+ this->gtinfo_->setGametype(this);
- this->setGametype(SmartPtr<Gametype>(this, false));
-
this->defaultControllableEntity_ = Class(Spectator);
this->bAutoStart_ = false;
@@ -97,7 +98,8 @@
{
if (this->isInitialized())
{
- this->gtinfo_->destroy();
+ if (this->gtinfo_)
+ this->gtinfo_->destroy();
ModifyConsoleCommand(__CC_addBots_name).setObject(NULL);
ModifyConsoleCommand(__CC_killBots_name).setObject(NULL);
Modified: code/branches/core7/src/orxonox/gametypes/Gametype.h
===================================================================
--- code/branches/core7/src/orxonox/gametypes/Gametype.h 2015-08-28 20:35:51 UTC (rev 10553)
+++ code/branches/core7/src/orxonox/gametypes/Gametype.h 2015-08-29 14:23:00 UTC (rev 10554)
@@ -175,7 +175,7 @@
virtual GSLevelMementoState* exportMementoState();
virtual void importMementoState(const std::vector<GSLevelMementoState*>& states);
- SmartPtr<GametypeInfo> gtinfo_;
+ WeakPtr<GametypeInfo> gtinfo_;
bool bAutoStart_;
bool bForceSpawn_;
More information about the Orxonox-commit
mailing list