changeset 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 724f3a5f3e96
children 6d09d310943b
files engine/core/model/structures/instance.cpp
diffstat 1 files changed, 15 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/engine/core/model/structures/instance.cpp	Thu Mar 19 17:14:56 2009 +0000
+++ b/engine/core/model/structures/instance.cpp	Thu Mar 19 17:56:59 2009 +0000
@@ -170,17 +170,17 @@
 	}
 
 	Instance::~Instance() {
-                std::vector<InstanceDeleteListener *>::iterator itor;
-                for(itor = m_deletelisteners.begin();
-                    itor != m_deletelisteners.end();
-                    ++itor) {
-                        (*itor)->onInstanceDeleted(this);
-                }
-                if(m_activity &&
-                   m_activity->m_actioninfo &&
-                   m_activity->m_actioninfo->m_leader) {
-                        m_activity->m_actioninfo->m_leader->removeDeleteListener(this);
-                }
+		std::vector<InstanceDeleteListener *>::iterator itor;
+		for(itor = m_deletelisteners.begin();
+			itor != m_deletelisteners.end();
+			++itor) {
+				(*itor)->onInstanceDeleted(this);
+		}
+
+		if(m_activity && m_activity->m_actioninfo) {
+			finalizeAction();
+		}
+
 		delete m_activity;
 		delete m_facinglocation;
 		delete m_visual;
@@ -401,6 +401,10 @@
 		assert(m_activity);
 		assert(m_activity->m_actioninfo);
 
+		if( m_activity->m_actioninfo->m_leader ) {
+			m_activity->m_actioninfo->m_leader->removeDeleteListener(this);
+		}
+
 		Action* action = m_activity->m_actioninfo->m_action;
 		delete m_activity->m_actioninfo;
 		m_activity->m_actioninfo = NULL;