1
0
forked from aniani/vim

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.
This commit is contained in:
Bram Moolenaar
2017-09-06 23:40:10 +02:00
parent 2e49b6b20c
commit e723c42836
5 changed files with 49 additions and 14 deletions

View File

@@ -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