comparison 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
comparison
equal deleted inserted replaced
12374:a3a35f113a36 12375:ab0d827151a1
1217 this_due = GET_TIMEDIFF(timer, now); 1217 this_due = GET_TIMEDIFF(timer, now);
1218 if (this_due <= 1) 1218 if (this_due <= 1)
1219 { 1219 {
1220 int save_timer_busy = timer_busy; 1220 int save_timer_busy = timer_busy;
1221 int save_vgetc_busy = vgetc_busy; 1221 int save_vgetc_busy = vgetc_busy;
1222 int did_emsg_save = did_emsg; 1222 int save_did_emsg = did_emsg;
1223 int called_emsg_save = called_emsg; 1223 int save_called_emsg = called_emsg;
1224 int did_throw_save = did_throw;
1225 int save_must_redraw = must_redraw; 1224 int save_must_redraw = must_redraw;
1226 1225 int save_trylevel = trylevel;
1226 int save_did_throw = did_throw;
1227 except_T *save_current_exception = current_exception;
1228
1229 /* Create a scope for running the timer callback, ignoring most of
1230 * the current scope, such as being inside a try/catch. */
1227 timer_busy = timer_busy > 0 || vgetc_busy > 0; 1231 timer_busy = timer_busy > 0 || vgetc_busy > 0;
1228 vgetc_busy = 0; 1232 vgetc_busy = 0;
1229 called_emsg = FALSE; 1233 called_emsg = FALSE;
1234 did_emsg = FALSE;
1235 did_uncaught_emsg = FALSE;
1230 must_redraw = 0; 1236 must_redraw = 0;
1237 trylevel = 0;
1238 did_throw = FALSE;
1239 current_exception = NULL;
1240
1231 timer->tr_firing = TRUE; 1241 timer->tr_firing = TRUE;
1232 timer_callback(timer); 1242 timer_callback(timer);
1233 timer->tr_firing = FALSE; 1243 timer->tr_firing = FALSE;
1244
1234 timer_next = timer->tr_next; 1245 timer_next = timer->tr_next;
1235 did_one = TRUE; 1246 did_one = TRUE;
1236 timer_busy = save_timer_busy; 1247 timer_busy = save_timer_busy;
1237 vgetc_busy = save_vgetc_busy; 1248 vgetc_busy = save_vgetc_busy;
1238 if (called_emsg) 1249 if (did_uncaught_emsg)
1239 {
1240 ++timer->tr_emsg_count; 1250 ++timer->tr_emsg_count;
1241 if (!did_throw_save && did_throw && current_exception != NULL) 1251 did_emsg = save_did_emsg;
1242 discard_current_exception(); 1252 called_emsg = save_called_emsg;
1243 } 1253 trylevel = save_trylevel;
1244 did_emsg = did_emsg_save; 1254 did_throw = save_did_throw;
1245 called_emsg = called_emsg_save; 1255 current_exception = save_current_exception;
1246 if (must_redraw != 0) 1256 if (must_redraw != 0)
1247 need_update_screen = TRUE; 1257 need_update_screen = TRUE;
1248 must_redraw = must_redraw > save_must_redraw 1258 must_redraw = must_redraw > save_must_redraw
1249 ? must_redraw : save_must_redraw; 1259 ? must_redraw : save_must_redraw;
1250 1260