Mercurial > fife-parpg
comparison 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 |
comparison
equal
deleted
inserted
replaced
338:d266506ff4f9 | 339:0fd74235b34d |
---|---|
228 return; | 228 return; |
229 } | 229 } |
230 std::vector<InstanceActionListener*>::iterator i = m_activity->m_actionlisteners.begin(); | 230 std::vector<InstanceActionListener*>::iterator i = m_activity->m_actionlisteners.begin(); |
231 while (i != m_activity->m_actionlisteners.end()) { | 231 while (i != m_activity->m_actionlisteners.end()) { |
232 if ((*i) == listener) { | 232 if ((*i) == listener) { |
233 m_activity->m_actionlisteners.erase(i); | 233 *i = NULL; |
234 return; | 234 return; |
235 } | 235 } |
236 ++i; | 236 ++i; |
237 } | 237 } |
238 FL_WARN(_log, "Cannot remove unknown listener"); | 238 FL_WARN(_log, "Cannot remove unknown listener"); |
420 delete m_activity->m_actioninfo; | 420 delete m_activity->m_actioninfo; |
421 m_activity->m_actioninfo = NULL; | 421 m_activity->m_actioninfo = NULL; |
422 | 422 |
423 std::vector<InstanceActionListener*>::iterator i = m_activity->m_actionlisteners.begin(); | 423 std::vector<InstanceActionListener*>::iterator i = m_activity->m_actionlisteners.begin(); |
424 while (i != m_activity->m_actionlisteners.end()) { | 424 while (i != m_activity->m_actionlisteners.end()) { |
425 (*i)->onInstanceActionFinished(this, action); | 425 if(*i) |
426 (*i)->onInstanceActionFinished(this, action); | |
426 ++i; | 427 ++i; |
427 } | 428 } |
429 m_activity->m_actionlisteners.erase( | |
430 std::remove(m_activity->m_actionlisteners.begin(), | |
431 m_activity->m_actionlisteners.end(), | |
432 (InstanceActionListener*)NULL), | |
433 m_activity->m_actionlisteners.end()); | |
428 } | 434 } |
429 | 435 |
430 Action* Instance::getCurrentAction() const { | 436 Action* Instance::getCurrentAction() const { |
431 if (m_activity && m_activity->m_actioninfo) { | 437 if (m_activity && m_activity->m_actioninfo) { |
432 return m_activity->m_actioninfo->m_action; | 438 return m_activity->m_actioninfo->m_action; |