]> granicus.if.org Git - icinga2/commitdiff
Windows: Fixed crash in Object::~Object().
authorGunnar Beutner <gunnar@beutner.name>
Thu, 7 Feb 2013 21:13:34 +0000 (22:13 +0100)
committerGunnar Beutner <gunnar@beutner.name>
Thu, 7 Feb 2013 21:13:34 +0000 (22:13 +0100)
lib/base/object.cpp
lib/base/object.h

index 041c5418e5019253440387623e6e13b221f6914e..10b591b5244ffbfe35126d30726e59a8f0481fa3 100644 (file)
@@ -27,8 +27,8 @@ using namespace icinga;
 Object::Object(void)
 {
 #ifdef _DEBUG
-       boost::mutex::scoped_lock lock(GetMutex());
-       GetAliveObjects().insert(this);
+       boost::mutex::scoped_lock lock(*GetMutex());
+       GetAliveObjects()->insert(this);
 #endif /* _DEBUG */
 }
 
@@ -38,8 +38,8 @@ Object::Object(void)
 Object::~Object(void)
 {
 #ifdef _DEBUG
-       boost::mutex::scoped_lock lock(GetMutex());
-       GetAliveObjects().erase(this);
+       boost::mutex::scoped_lock lock(*GetMutex());
+       GetAliveObjects()->erase(this);
 #endif /* _DEBUG */
 }
 
@@ -50,7 +50,7 @@ Object::~Object(void)
  */
 void Object::Hold(void)
 {
-       boost::mutex::scoped_lock lock(GetMutex());
+       boost::mutex::scoped_lock lock(*GetMutex());
        GetHeldObjects().push_back(GetSelf());
 }
 
@@ -59,7 +59,7 @@ void Object::Hold(void)
  */
 void Object::ClearHeldObjects(void)
 {
-       boost::mutex::scoped_lock lock(GetMutex());
+       boost::mutex::scoped_lock lock(*GetMutex());
        GetHeldObjects().clear();
 }
 
@@ -81,8 +81,8 @@ Object::SharedPtrHolder Object::GetSelf(void)
  */
 int Object::GetAliveObjectsCount(void)
 {
-       boost::mutex::scoped_lock lock(GetMutex());
-       return GetAliveObjects().size();
+       boost::mutex::scoped_lock lock(*GetMutex());
+       return GetAliveObjects()->size();
 }
 
 /**
@@ -95,9 +95,9 @@ void Object::PrintMemoryProfile(void)
        ofstream dictfp("dictionaries.dump.tmp");
 
        {
-               boost::mutex::scoped_lock lock(GetMutex());
+               boost::mutex::scoped_lock lock(*GetMutex());
                set<Object *>::iterator it;
-               BOOST_FOREACH(Object *obj, GetAliveObjects()) {
+               BOOST_FOREACH(Object *obj, *GetAliveObjects()) {
                        pair<map<String, int>::iterator, bool> tt;
                        tt = types.insert(make_pair(Utility::GetTypeName(typeid(*obj)), 1));
                        if (!tt.second)
@@ -130,9 +130,9 @@ void Object::PrintMemoryProfile(void)
  *
  * @returns currently active objects
  */
-set<Object *>Object::GetAliveObjects(void)
+set<Object *> *Object::GetAliveObjects(void)
 {
-       static set<Object *> aliveObjects;
+       static set<Object *> *aliveObjects = new set<Object *>();
        return aliveObjects;
 }
 #endif /* _DEBUG */
@@ -142,9 +142,9 @@ set<Object *>& Object::GetAliveObjects(void)
  *
  * @returns a mutex
  */
-boost::mutexObject::GetMutex(void)
+boost::mutex *Object::GetMutex(void)
 {
-       static boost::mutex mutex;
+       static boost::mutex *mutex = new boost::mutex();
        return mutex;
 }
 
index 940f4837fcb993867bcf732799896984cc665847..fa0fb4c9500408208b4171a269f35e42ce80c6fc 100644 (file)
@@ -109,8 +109,8 @@ private:
        Object(const Object& other);
        Object& operator=(const Object& rhs);
 
-       static boost::mutexGetMutex(void);
-       static set<Object *>GetAliveObjects(void);
+       static boost::mutex *GetMutex(void);
+       static set<Object *> *GetAliveObjects(void);
        static vector<Object::Ptr>& GetHeldObjects(void);
 };