comparison src/misc2.c @ 17284:d3b15a3789e1 v8.1.1641

patch 8.1.1641: garbage collection may run at a wrong moment commit https://github.com/vim/vim/commit/6cc7e21412487ff8bd531c73ac9325f5ba2409a9 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jul 7 14:05:24 2019 +0200 patch 8.1.1641: garbage collection may run at a wrong moment Problem: Garbage collection may run at a wrong moment. (Trygve Aaberge) Solution: Postpone garbage collection while parsing messages. (closes https://github.com/vim/vim/issues/4620)
author Bram Moolenaar <Bram@vim.org>
date Sun, 07 Jul 2019 14:15:05 +0200
parents a9556c0ba457
children e24bbd061233
comparison
equal deleted inserted replaced
17283:6ea5e2c14ea4 17284:d3b15a3789e1
4442 void 4442 void
4443 parse_queued_messages(void) 4443 parse_queued_messages(void)
4444 { 4444 {
4445 win_T *old_curwin = curwin; 4445 win_T *old_curwin = curwin;
4446 int i; 4446 int i;
4447 int save_may_garbage_collect = may_garbage_collect;
4447 4448
4448 // Do not handle messages while redrawing, because it may cause buffers to 4449 // Do not handle messages while redrawing, because it may cause buffers to
4449 // change or be wiped while they are being redrawn. 4450 // change or be wiped while they are being redrawn.
4450 if (updating_screen) 4451 if (updating_screen)
4451 return; 4452 return;
4453
4454 // may_garbage_collect is set in main_loop() to do garbage collection when
4455 // blocking to wait on a character. We don't want that while parsing
4456 // messages, a callback may invoke vgetc() while lists and dicts are in use
4457 // in the call stack.
4458 may_garbage_collect = FALSE;
4452 4459
4453 // Loop when a job ended, but don't keep looping forever. 4460 // Loop when a job ended, but don't keep looping forever.
4454 for (i = 0; i < MAX_REPEAT_PARSE; ++i) 4461 for (i = 0; i < MAX_REPEAT_PARSE; ++i)
4455 { 4462 {
4456 // For Win32 mch_breakcheck() does not check for input, do it here. 4463 // For Win32 mch_breakcheck() does not check for input, do it here.
4482 # ifdef FEAT_TERMINAL 4489 # ifdef FEAT_TERMINAL
4483 free_unused_terminals(); 4490 free_unused_terminals();
4484 # endif 4491 # endif
4485 break; 4492 break;
4486 } 4493 }
4494
4495 may_garbage_collect = save_may_garbage_collect;
4487 4496
4488 // If the current window changed we need to bail out of the waiting loop. 4497 // If the current window changed we need to bail out of the waiting loop.
4489 // E.g. when a job exit callback closes the terminal window. 4498 // E.g. when a job exit callback closes the terminal window.
4490 if (curwin != old_curwin) 4499 if (curwin != old_curwin)
4491 ins_char_typebuf(K_IGNORE); 4500 ins_char_typebuf(K_IGNORE);