Mercurial > MadButterfly
comparison src/observer.c @ 202:75ec0124202a
Commit merged between 200 and 201
author | wycc@wycc-desktop |
---|---|
date | Tue, 09 Dec 2008 23:34:05 +0800 |
parents | f9d507a3e1d9 45d9a1e2764d |
children | 748896358da2 |
comparison
equal
deleted
inserted
replaced
201:31933f9ee70e | 202:75ec0124202a |
---|---|
49 | 49 |
50 | 50 |
51 void subject_notify(subject_t *subject, event_t *evt) { | 51 void subject_notify(subject_t *subject, event_t *evt) { |
52 ob_factory_t *factory = subject->factory; | 52 ob_factory_t *factory = subject->factory; |
53 observer_t *observer; | 53 observer_t *observer; |
54 subject_t *old_subject; | |
54 | 55 |
55 evt->tgt = subject; | 56 evt->tgt = subject; |
56 while(subject) { | 57 while(subject) { |
57 /*! | 58 /*! |
58 * \note What is happend when the subject is freed by observer? | 59 * \note What is happend when the subject is freed by observer? |
68 if (observer->type == EVT_ANY || observer->type == evt->type) | 69 if (observer->type == EVT_ANY || observer->type == evt->type) |
69 observer->hdr(evt, observer->arg); | 70 observer->hdr(evt, observer->arg); |
70 } | 71 } |
71 | 72 |
72 subject->flags &= ~SUBF_BUSY; | 73 subject->flags &= ~SUBF_BUSY; |
73 if(subject->flags & SUBF_FREE) | 74 |
74 subject_free(subject); | 75 old_subject = subject; |
75 | 76 subject = factory->get_parent_subject(factory, subject); |
76 if(subject->flags & SUBF_STOP_PROPAGATE) | 77 |
78 if(old_subject->flags & SUBF_FREE) | |
79 subject_free(old_subject); | |
80 | |
81 if(old_subject->flags & SUBF_STOP_PROPAGATE) | |
77 break; | 82 break; |
78 | |
79 subject = factory->get_parent_subject(factory, subject); | |
80 } | 83 } |
81 | |
82 } | 84 } |
83 | 85 |
84 observer_t *subject_add_observer(subject_t *subject, | 86 observer_t *subject_add_observer(subject_t *subject, |
85 evt_handler hdr, void *arg) { | 87 evt_handler hdr, void *arg) { |
86 ob_factory_t *factory = subject->factory; | 88 ob_factory_t *factory = subject->factory; |