Mercurial > fife-parpg
comparison engine/core/model/structures/instance.cpp @ 219:852da06fc922
Moved the removal of deletelistener in instance.cpp to finalizeAction to assure that no duplicate addDeleteLstener
calls lead to segfaults.
Whitespace cleanup.
author | phoku@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Thu, 19 Mar 2009 17:56:59 +0000 |
parents | be246fb3a0df |
children | 7887f3854862 |
comparison
equal
deleted
inserted
replaced
218:724f3a5f3e96 | 219:852da06fc922 |
---|---|
168 m_facinglocation(NULL), | 168 m_facinglocation(NULL), |
169 m_visual(NULL) { | 169 m_visual(NULL) { |
170 } | 170 } |
171 | 171 |
172 Instance::~Instance() { | 172 Instance::~Instance() { |
173 std::vector<InstanceDeleteListener *>::iterator itor; | 173 std::vector<InstanceDeleteListener *>::iterator itor; |
174 for(itor = m_deletelisteners.begin(); | 174 for(itor = m_deletelisteners.begin(); |
175 itor != m_deletelisteners.end(); | 175 itor != m_deletelisteners.end(); |
176 ++itor) { | 176 ++itor) { |
177 (*itor)->onInstanceDeleted(this); | 177 (*itor)->onInstanceDeleted(this); |
178 } | 178 } |
179 if(m_activity && | 179 |
180 m_activity->m_actioninfo && | 180 if(m_activity && m_activity->m_actioninfo) { |
181 m_activity->m_actioninfo->m_leader) { | 181 finalizeAction(); |
182 m_activity->m_actioninfo->m_leader->removeDeleteListener(this); | 182 } |
183 } | 183 |
184 delete m_activity; | 184 delete m_activity; |
185 delete m_facinglocation; | 185 delete m_facinglocation; |
186 delete m_visual; | 186 delete m_visual; |
187 } | 187 } |
188 | 188 |
398 | 398 |
399 void Instance::finalizeAction() { | 399 void Instance::finalizeAction() { |
400 FL_DBG(_log, "finalizing action"); | 400 FL_DBG(_log, "finalizing action"); |
401 assert(m_activity); | 401 assert(m_activity); |
402 assert(m_activity->m_actioninfo); | 402 assert(m_activity->m_actioninfo); |
403 | |
404 if( m_activity->m_actioninfo->m_leader ) { | |
405 m_activity->m_actioninfo->m_leader->removeDeleteListener(this); | |
406 } | |
403 | 407 |
404 Action* action = m_activity->m_actioninfo->m_action; | 408 Action* action = m_activity->m_actioninfo->m_action; |
405 delete m_activity->m_actioninfo; | 409 delete m_activity->m_actioninfo; |
406 m_activity->m_actioninfo = NULL; | 410 m_activity->m_actioninfo = NULL; |
407 | 411 |