X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fnetradiant.git;a=blobdiff_plain;f=libs%2Fentitylib.h;h=4a34f0a53722a910538d2b8f5bd45839417988ba;hp=b9e93002ee21666436253c5d9010a41c707450ae;hb=6ee91d153ea09f2dafa62ed2f022f4183c090168;hpb=ba55f1bbf627594f91a7e72706655bb71dca4db4 diff --git a/libs/entitylib.h b/libs/entitylib.h index b9e93002..4a34f0a5 100644 --- a/libs/entitylib.h +++ b/libs/entitylib.h @@ -304,13 +304,11 @@ public: }; -typedef Callback1 KeyObserver; - /// \brief A key/value pair of strings. /// /// - Notifies observers when value changes - value changes to "" on destruction. /// - Provides undo support through the global undo system. -class KeyValue +class KeyValue : public EntityKeyValue { typedef UnsortedSet KeyObservers; @@ -414,13 +412,6 @@ class EntityKeyValues : public Entity public: typedef KeyValue Value; - class Observer - { - public: - virtual void insert(const char* key, Value& value) = 0; - virtual void erase(const char* key, Value& value) = 0; - }; - static StringPool& getPool() { return Static::instance(); @@ -553,6 +544,11 @@ public: } ~EntityKeyValues() { + for(Observers::iterator i = m_observers.begin(); i != m_observers.end();) + { + // post-increment to allow current element to be removed safely + (*i++)->clear(); + } ASSERT_MESSAGE(m_observers.empty(), "EntityKeyValues::~EntityKeyValues: observers still attached"); }