[Orxonox-commit 5638] r10298 - code/trunk/src/libraries/core
landauf at orxonox.net
landauf at orxonox.net
Mon Mar 2 23:18:45 CET 2015
Author: landauf
Date: 2015-03-02 23:18:45 +0100 (Mon, 02 Mar 2015)
New Revision: 10298
Modified:
code/trunk/src/libraries/core/BaseObject.h
code/trunk/src/libraries/core/Namespace.cc
Log:
fixed potential crash during level-unloading: Namespace is a context and is thus potentially used by other objects -> store a smartPtr on the namespace object
Modified: code/trunk/src/libraries/core/BaseObject.h
===================================================================
--- code/trunk/src/libraries/core/BaseObject.h 2015-03-01 21:11:26 UTC (rev 10297)
+++ code/trunk/src/libraries/core/BaseObject.h 2015-03-02 22:18:45 UTC (rev 10298)
@@ -137,8 +137,8 @@
inline const std::set<Template*>& getTemplates() const
{ return this->templates_; }
- virtual inline void setNamespace(Namespace* ns) { this->namespace_ = ns; }
- inline Namespace* getNamespace() const { return this->namespace_; }
+ inline void setNamespace(const SmartPtr<Namespace>& ns) { this->namespace_ = ns; }
+ inline const SmartPtr<Namespace>& getNamespace() const { return this->namespace_; }
inline void setCreator(BaseObject* creator) { this->creator_ = creator; }
inline BaseObject* getCreator() const { return this->creator_; }
@@ -221,7 +221,7 @@
Element* lastLoadedXMLElement_; //!< Non 0 if the TinyXML attributes have already been copied to our own lowercase map
std::map<std::string, std::string> xmlAttributes_; //!< Lowercase XML attributes
std::string loaderIndentation_; //!< Indentation of the debug output in the Loader
- Namespace* namespace_;
+ SmartPtr<Namespace> namespace_;
BaseObject* creator_;
SmartPtr<Scene> scene_;
uint32_t sceneID_;
Modified: code/trunk/src/libraries/core/Namespace.cc
===================================================================
--- code/trunk/src/libraries/core/Namespace.cc 2015-03-01 21:11:26 UTC (rev 10297)
+++ code/trunk/src/libraries/core/Namespace.cc 2015-03-02 22:18:45 UTC (rev 10298)
@@ -45,6 +45,8 @@
operator_("or")
{
RegisterObject(Namespace);
+
+ this->setNamespace(SmartPtr<Namespace>(this, false));
}
Namespace::~Namespace()
More information about the Orxonox-commit
mailing list