patch 9.0.1571: RedrawingDisabled not used consistently
Problem: RedrawingDisabled not used consistently.
Solution: Avoid RedrawingDisabled going negative. Set RedrawingDisabled in
win_split_ins(). (closes #11961)
diff --git a/src/window.c b/src/window.c
index 18f07b1..926a3f3 100644
--- a/src/window.c
+++ b/src/window.c
@@ -950,6 +950,10 @@
int minheight;
int wmh1;
int did_set_fraction = FALSE;
+ int retval = FAIL;
+
+ // Do not redraw here, curwin->w_buffer may be invalid.
+ ++RedrawingDisabled;
if (flags & WSP_TOP)
oldwin = firstwin;
@@ -964,7 +968,7 @@
if (VISIBLE_HEIGHT(oldwin) <= p_wmh && new_wp == NULL)
{
emsg(_(e_not_enough_room));
- return FAIL;
+ goto theend;
}
need_status = STATUS_HEIGHT;
}
@@ -1022,7 +1026,7 @@
if (available < needed && new_wp == NULL)
{
emsg(_(e_not_enough_room));
- return FAIL;
+ goto theend;
}
if (new_size == 0)
new_size = oldwin->w_width / 2;
@@ -1105,7 +1109,7 @@
if (available < needed && new_wp == NULL)
{
emsg(_(e_not_enough_room));
- return FAIL;
+ goto theend;
}
oldwin_height = oldwin->w_height;
if (need_status)
@@ -1188,13 +1192,13 @@
if (new_wp == NULL)
{
if (wp == NULL)
- return FAIL;
+ goto theend;
new_frame(wp);
if (wp->w_frame == NULL)
{
win_free(wp, NULL);
- return FAIL;
+ goto theend;
}
// make the contents of the new window the same as the current one
@@ -1435,8 +1439,12 @@
p_wiw = i;
else
p_wh = i;
+ retval = OK;
- return OK;
+theend:
+ if (RedrawingDisabled > 0)
+ --RedrawingDisabled;
+ return retval;
}
@@ -2460,7 +2468,8 @@
}
}
- --RedrawingDisabled;
+ if (RedrawingDisabled > 0)
+ --RedrawingDisabled;
if (count != tabpage_index(NULL))
apply_autocmds(EVENT_TABCLOSED, NULL, NULL, FALSE, curbuf);