Mercurial > MadButterfly
diff src/animate.c @ 153:9870b049b7f6
Make mb_progm_abort() work.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Sat, 27 Sep 2008 02:40:42 +0800 |
parents | 6a8588df68af |
children | 6749f6639924 |
line wrap: on
line diff
--- a/src/animate.c Fri Sep 26 17:56:08 2008 +0800 +++ b/src/animate.c Sat Sep 27 02:40:42 2008 +0800 @@ -98,6 +98,7 @@ int first_playing; /*!< first playing word. */ mb_tman_t *tman; subject_t *complete; /*!< notify when a program is completed. */ + mb_timer_t *cur_timer; int n_words; int max_words; @@ -290,6 +291,7 @@ timer = mb_tman_timeout(progm->tman, &next_tmo, mb_progm_step, progm); } else { + /* Make program to complete. */ #ifndef UNITTEST factory = rdman_get_ob_factory(progm->rdman); comp_evt.event.type = EVT_PROGM_COMPLETE; @@ -297,6 +299,7 @@ comp_evt.progm = progm; subject_notify(factory, progm->complete, &comp_evt.event); #endif /* UNITTEST */ + progm->cur_timer = NULL; } } @@ -329,10 +332,17 @@ timer = mb_tman_timeout(tman, &progm->words[0].abs_start, mb_progm_step, progm); ASSERT(timer != NULL); + + /* We need timer to abort it. */ + progm->cur_timer = timer; } -void mb_progm_abort(mb_progm_t *progm, mb_tman_t *tman) { +void mb_progm_abort(mb_progm_t *progm) { /*! \todo Make sure abort release resources. */ + if(progm->cur_timer) { + mb_tman_remove(progm->tman, progm->cur_timer); + progm->cur_timer = NULL; + } } /*! \brief Return event subject for completion of a program.