diff src/observer.c @ 194:45d9a1e2764d

Add mb_subtree_free animate action and fix bugs. - Free members of a coord in rdman_coord_subtree_free(). - Fix core dump issue of subject_notify() that can not free subjects well.
author Thinker K.F. Li <thinker@branda.to>
date Wed, 19 Nov 2008 20:53:40 +0800
parents 54fdc2a65242
children 75ec0124202a
line wrap: on
line diff
--- a/src/observer.c	Wed Nov 19 11:26:01 2008 +0800
+++ b/src/observer.c	Wed Nov 19 20:53:40 2008 +0800
@@ -51,6 +51,7 @@
 void subject_notify(subject_t *subject, event_t *evt) {
     ob_factory_t *factory = subject->factory;
     observer_t *observer;
+    subject_t *old_subject;
 
     evt->tgt = subject;
     while(subject) {
@@ -69,15 +70,16 @@
 	}
 
 	subject->flags &= ~SUBF_BUSY;
-	if(subject->flags & SUBF_FREE)
-	    subject_free(subject);
+
+	old_subject = subject;
+	subject = factory->get_parent_subject(factory, subject);
 
-	if(subject->flags & SUBF_STOP_PROPAGATE)
+	if(old_subject->flags & SUBF_FREE)
+	    subject_free(old_subject);
+
+	if(old_subject->flags & SUBF_STOP_PROPAGATE)
 	    break;
-
-	subject = factory->get_parent_subject(factory, subject);
     }
-
 }
 
 observer_t *subject_add_observer(subject_t *subject,