diff --git a/lemon/bits/alteration_notifier.h b/lemon/bits/alteration_notifier.h --- a/lemon/bits/alteration_notifier.h +++ b/lemon/bits/alteration_notifier.h @@ -23,6 +23,7 @@ #include #include +#include //\ingroup graphbits //\file @@ -251,7 +252,7 @@ typedef std::list Observers; Observers _observers; - + lemon::bits::Lock _lock; public: @@ -332,14 +333,18 @@ protected: void attach(ObserverBase& observer) { + _lock.lock(); observer._index = _observers.insert(_observers.begin(), &observer); observer._notifier = this; + _lock.unlock(); } void detach(ObserverBase& observer) { + _lock.lock(); _observers.erase(observer._index); observer._index = _observers.end(); observer._notifier = 0; + _lock.unlock(); } public: