diff engine/core/model/structures/instance.cpp @ 339:0fd74235b34d

Fixes. * The signature of InstanceTree.add/remove is adapted to the new behaviour. * Add/Remove ActionListeners from Instances should now be reentrant. * Small compile warning fixed.
author phoku@33b003aa-7bff-0310-803a-e67f0ece8222
date Mon, 24 Aug 2009 18:52:49 +0000
parents d266506ff4f9
children 48c38e92e2bd
line wrap: on
line diff
--- a/engine/core/model/structures/instance.cpp	Mon Aug 24 18:32:03 2009 +0000
+++ b/engine/core/model/structures/instance.cpp	Mon Aug 24 18:52:49 2009 +0000
@@ -230,7 +230,7 @@
 		std::vector<InstanceActionListener*>::iterator i = m_activity->m_actionlisteners.begin();
 		while (i != m_activity->m_actionlisteners.end()) {
 			if ((*i) == listener) {
-				m_activity->m_actionlisteners.erase(i);
+				*i = NULL;
 				return;
 			}
 			++i;
@@ -422,9 +422,15 @@
 
 		std::vector<InstanceActionListener*>::iterator i = m_activity->m_actionlisteners.begin();
 		while (i != m_activity->m_actionlisteners.end()) {
-			(*i)->onInstanceActionFinished(this, action);
+			if(*i)
+				(*i)->onInstanceActionFinished(this, action);
 			++i;
 		}
+		m_activity->m_actionlisteners.erase(
+			std::remove(m_activity->m_actionlisteners.begin(),
+				m_activity->m_actionlisteners.end(),
+				(InstanceActionListener*)NULL),
+			m_activity->m_actionlisteners.end());
 	}
 
 	Action* Instance::getCurrentAction() const {