[icinga-checkins] icinga.org: icinga2/master: Bugfix: DynamicType::GetObjects() is relying on static constructors order.

git at icinga.org git at icinga.org
Thu Feb 7 22:37:42 CET 2013


Module: icinga2
Branch: master
Commit: 220a1e319bcf7f99662daeb42647dc675cb2d5fc
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=220a1e319bcf7f99662daeb42647dc675cb2d5fc

Author: Gunnar Beutner <gunnar at beutner.name>
Date:   Thu Feb  7 22:37:34 2013 +0100

Bugfix: DynamicType::GetObjects() is relying on static constructors order.

---

 lib/base/dynamictype.cpp |   14 ++++++++------
 lib/base/dynamictype.h   |    4 +---
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/lib/base/dynamictype.cpp b/lib/base/dynamictype.cpp
index 05efe7b..163acbb 100644
--- a/lib/base/dynamictype.cpp
+++ b/lib/base/dynamictype.cpp
@@ -43,7 +43,9 @@ DynamicType::TypeMap& DynamicType::GetTypes(void)
 
 DynamicType::NameMap& DynamicType::GetObjects(void)
 {
-	return m_Objects;
+	static NameMap objects;
+
+	return objects;
 }
 
 String DynamicType::GetName(void) const
@@ -53,19 +55,19 @@ String DynamicType::GetName(void) const
 
 void DynamicType::RegisterObject(const DynamicObject::Ptr& object)
 {
-	m_Objects[object->GetName()] = object;
+	GetObjects()[object->GetName()] = object;
 }
 
 void DynamicType::UnregisterObject(const DynamicObject::Ptr& object)
 {
-	m_Objects.erase(object->GetName());
+	GetObjects().erase(object->GetName());
 }
 
-DynamicObject::Ptr DynamicType::GetObject(const String& name) const
+DynamicObject::Ptr DynamicType::GetObject(const String& name)
 {
-	DynamicType::NameMap::const_iterator nt = m_Objects.find(name);
+	DynamicType::NameMap::const_iterator nt = GetObjects().find(name);
 
-	if (nt == m_Objects.end())
+	if (nt == GetObjects().end())
 		return DynamicObject::Ptr();
 
 	return nt->second;
diff --git a/lib/base/dynamictype.h b/lib/base/dynamictype.h
index b2bbd6e..4d48a15 100644
--- a/lib/base/dynamictype.h
+++ b/lib/base/dynamictype.h
@@ -49,7 +49,7 @@ public:
 	static bool TypeExists(const String& name);
 	
 	DynamicObject::Ptr CreateObject(const Dictionary::Ptr& serializedUpdate) const;
-	DynamicObject::Ptr GetObject(const String& name) const;
+	DynamicObject::Ptr GetObject(const String& name);
 
 	void RegisterObject(const DynamicObject::Ptr& object);
 	void UnregisterObject(const DynamicObject::Ptr& object);
@@ -67,8 +67,6 @@ private:
 	String m_Name;
 	ObjectFactory m_ObjectFactory;
 	map<String, DynamicAttributeType> m_Attributes;
-
-	NameMap m_Objects;
 };
 
 /**





More information about the icinga-checkins mailing list