Skip to content

Commit 4778b4d

Browse files
committed
patch 8.2.1948: GUI: crash when handling message while closing a window
Problem: GUI: crash when handling message while closing a window. (Srinath Avadhanula) Solution: Don't handle message while closing a window. (closes #7250)
1 parent c136a35 commit 4778b4d

4 files changed

Lines changed: 18 additions & 1 deletion

File tree

src/getchar.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2155,7 +2155,8 @@ parse_queued_messages(void)
21552155

21562156
// Do not handle messages while redrawing, because it may cause buffers to
21572157
// change or be wiped while they are being redrawn.
2158-
if (updating_screen)
2158+
// Also bail out when parsing messages was explicitly disabled.
2159+
if (updating_screen || dont_parse_messages)
21592160
return;
21602161

21612162
// If memory allocation fails during startup we'll exit but curbuf or

src/globals.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,12 @@ EXTERN int diff_need_scrollbind INIT(= FALSE);
581581
// ('lines' and 'rows') must not be changed.
582582
EXTERN int updating_screen INIT(= FALSE);
583583

584+
#ifdef MESSAGE_QUEUE
585+
// While closing windows or buffers messages should not be handled to avoid
586+
// using invalid windows or buffers.
587+
EXTERN int dont_parse_messages INIT(= FALSE);
588+
#endif
589+
584590
#ifdef FEAT_MENU
585591
// The root of the menu hierarchy.
586592
EXTERN vimmenu_T *root_menu INIT(= NULL);

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
1948,
753755
/**/
754756
1947,
755757
/**/

src/window.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2569,7 +2569,12 @@ win_close(win_T *win, int free_buf)
25692569

25702570
// Now we are really going to close the window. Disallow any autocommand
25712571
// to split a window to avoid trouble.
2572+
// Also bail out of parse_queued_messages() to avoid it tries to update the
2573+
// screen.
25722574
++split_disallowed;
2575+
#ifdef MESSAGE_QUEUE
2576+
++dont_parse_messages;
2577+
#endif
25732578

25742579
// Free the memory used for the window and get the window that received
25752580
// the screen space.
@@ -2626,6 +2631,9 @@ win_close(win_T *win, int free_buf)
26262631
}
26272632

26282633
--split_disallowed;
2634+
#ifdef MESSAGE_QUEUE
2635+
--dont_parse_messages;
2636+
#endif
26292637

26302638
/*
26312639
* If last window has a status line now and we don't want one,

0 commit comments

Comments
 (0)