Mercurial > vim
diff src/ex_cmds2.c @ 12375:ab0d827151a1 v8.0.1067
patch 8.0.1067: try/catch in timer does not prevent it from being stopped
commit https://github.com/vim/vim/commit/e723c42836d971180d1bf9f98916966c5543fff1
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Sep 6 23:40:10 2017 +0200
patch 8.0.1067: try/catch in timer does not prevent it from being stopped
Problem: Using try/catch in timer does not prevent it from being stopped.
Solution: Reset the exception context and use did_emsg instead of
called_emsg.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Wed, 06 Sep 2017 23:45:04 +0200 |
parents | d0b039e2ed56 |
children | 937356f8f8d6 |
line wrap: on
line diff
--- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -1219,30 +1219,40 @@ check_due_timer(void) { int save_timer_busy = timer_busy; int save_vgetc_busy = vgetc_busy; - int did_emsg_save = did_emsg; - int called_emsg_save = called_emsg; - int did_throw_save = did_throw; + int save_did_emsg = did_emsg; + int save_called_emsg = called_emsg; int save_must_redraw = must_redraw; - + int save_trylevel = trylevel; + int save_did_throw = did_throw; + except_T *save_current_exception = current_exception; + + /* Create a scope for running the timer callback, ignoring most of + * the current scope, such as being inside a try/catch. */ timer_busy = timer_busy > 0 || vgetc_busy > 0; vgetc_busy = 0; called_emsg = FALSE; + did_emsg = FALSE; + did_uncaught_emsg = FALSE; must_redraw = 0; + trylevel = 0; + did_throw = FALSE; + current_exception = NULL; + timer->tr_firing = TRUE; timer_callback(timer); timer->tr_firing = FALSE; + timer_next = timer->tr_next; did_one = TRUE; timer_busy = save_timer_busy; vgetc_busy = save_vgetc_busy; - if (called_emsg) - { + if (did_uncaught_emsg) ++timer->tr_emsg_count; - if (!did_throw_save && did_throw && current_exception != NULL) - discard_current_exception(); - } - did_emsg = did_emsg_save; - called_emsg = called_emsg_save; + did_emsg = save_did_emsg; + called_emsg = save_called_emsg; + trylevel = save_trylevel; + did_throw = save_did_throw; + current_exception = save_current_exception; if (must_redraw != 0) need_update_screen = TRUE; must_redraw = must_redraw > save_must_redraw