diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2014-01-31 16:18:03 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2014-02-09 12:55:40 +0100 |
commit | a09e46f4560d2a4ff273c27a133d288b1f230db8 (patch) | |
tree | 352bcc9ffa63841d72250e29c4d5b2964db04bbc /src/plugins/trigger | |
parent | 1496c8a25c22ffe998a29426e8ba8b3c82736ca6 (diff) | |
download | weechat-a09e46f4560d2a4ff273c27a133d288b1f230db8.zip |
trigger: remove the timer hook pointer during the last timer call
Diffstat (limited to 'src/plugins/trigger')
-rw-r--r-- | src/plugins/trigger/trigger-callback.c | 15 | ||||
-rw-r--r-- | src/plugins/trigger/trigger.c | 3 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/plugins/trigger/trigger-callback.c b/src/plugins/trigger/trigger-callback.c index 116bb318e..04f629bf3 100644 --- a/src/plugins/trigger/trigger-callback.c +++ b/src/plugins/trigger/trigger-callback.c @@ -645,7 +645,7 @@ trigger_callback_timer_cb (void *data, int remaining_calls) struct t_trigger *trigger; struct t_hashtable *extra_vars; char str_temp[128]; - int rc; + int rc, i; time_t date; struct tm *date_tmp; @@ -654,6 +654,19 @@ trigger_callback_timer_cb (void *data, int remaining_calls) if (!trigger || trigger->hook_running) return WEECHAT_RC_OK; + /* + * remove the hook if this is the last call to timer + * (because WeeChat will remove the hook after this call, so the pointer + * will become invalid) + */ + if ((remaining_calls == 0) && trigger->hooks) + { + for (i = 0; i < trigger->hooks_count; i++) + { + trigger->hooks[i] = NULL; + } + } + trigger->hook_count_cb++; trigger->hook_running = 1; diff --git a/src/plugins/trigger/trigger.c b/src/plugins/trigger/trigger.c index e0f6e93a8..159580535 100644 --- a/src/plugins/trigger/trigger.c +++ b/src/plugins/trigger/trigger.c @@ -414,7 +414,8 @@ trigger_unhook (struct t_trigger *trigger) { for (i = 0; i < trigger->hooks_count; i++) { - weechat_unhook (trigger->hooks[i]); + if (trigger->hooks[i]) + weechat_unhook (trigger->hooks[i]); } free (trigger->hooks); trigger->hooks = NULL; |