forked from aniani/vim
patch 8.0.0948: crash if timer closes window while dragging status line
Problem: Crash if timer closes window while dragging status line. Solution: Check if the window still exists. (Yasuhiro Matsumoto, closes #1979)
This commit is contained in:
@@ -9418,7 +9418,7 @@ ins_mousescroll(int dir)
|
|||||||
{
|
{
|
||||||
pos_T tpos;
|
pos_T tpos;
|
||||||
# if defined(FEAT_WINDOWS)
|
# if defined(FEAT_WINDOWS)
|
||||||
win_T *old_curwin = curwin;
|
win_T *old_curwin = curwin, *wp;
|
||||||
# endif
|
# endif
|
||||||
# ifdef FEAT_INS_EXPAND
|
# ifdef FEAT_INS_EXPAND
|
||||||
int did_scroll = FALSE;
|
int did_scroll = FALSE;
|
||||||
@@ -9435,7 +9435,10 @@ ins_mousescroll(int dir)
|
|||||||
col = mouse_col;
|
col = mouse_col;
|
||||||
|
|
||||||
/* find the window at the pointer coordinates */
|
/* find the window at the pointer coordinates */
|
||||||
curwin = mouse_find_win(&row, &col);
|
wp = mouse_find_win(&row, &col);
|
||||||
|
if (wp == NULL)
|
||||||
|
return;
|
||||||
|
curwin = wp;
|
||||||
curbuf = curwin->w_buffer;
|
curbuf = curwin->w_buffer;
|
||||||
}
|
}
|
||||||
if (curwin == old_curwin)
|
if (curwin == old_curwin)
|
||||||
|
@@ -4382,6 +4382,8 @@ f_getchar(typval_T *argvars, typval_T *rettv)
|
|||||||
/* Find the window at the mouse coordinates and compute the
|
/* Find the window at the mouse coordinates and compute the
|
||||||
* text position. */
|
* text position. */
|
||||||
win = mouse_find_win(&row, &col);
|
win = mouse_find_win(&row, &col);
|
||||||
|
if (win == NULL)
|
||||||
|
return;
|
||||||
(void)mouse_comp_pos(win, &row, &col, &lnum);
|
(void)mouse_comp_pos(win, &row, &col, &lnum);
|
||||||
# ifdef FEAT_WINDOWS
|
# ifdef FEAT_WINDOWS
|
||||||
for (wp = firstwin; wp != win; wp = wp->w_next)
|
for (wp = firstwin; wp != win; wp = wp->w_next)
|
||||||
|
@@ -4933,7 +4933,7 @@ gui_mouse_correct(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find window where the mouse pointer "y" coordinate is in.
|
* Find window where the mouse pointer "x" / "y" coordinate is in.
|
||||||
*/
|
*/
|
||||||
static win_T *
|
static win_T *
|
||||||
xy2win(int x UNUSED, int y UNUSED)
|
xy2win(int x UNUSED, int y UNUSED)
|
||||||
@@ -4948,6 +4948,8 @@ xy2win(int x UNUSED, int y UNUSED)
|
|||||||
if (row < 0 || col < 0) /* before first window */
|
if (row < 0 || col < 0) /* before first window */
|
||||||
return NULL;
|
return NULL;
|
||||||
wp = mouse_find_win(&row, &col);
|
wp = mouse_find_win(&row, &col);
|
||||||
|
if (wp == NULL)
|
||||||
|
return NULL;
|
||||||
# ifdef FEAT_MOUSESHAPE
|
# ifdef FEAT_MOUSESHAPE
|
||||||
if (State == HITRETURN || State == ASKMORE)
|
if (State == HITRETURN || State == ASKMORE)
|
||||||
{
|
{
|
||||||
|
@@ -4627,7 +4627,7 @@ nv_screengo(oparg_T *oap, int dir, long dist)
|
|||||||
nv_mousescroll(cmdarg_T *cap)
|
nv_mousescroll(cmdarg_T *cap)
|
||||||
{
|
{
|
||||||
# ifdef FEAT_WINDOWS
|
# ifdef FEAT_WINDOWS
|
||||||
win_T *old_curwin = curwin;
|
win_T *old_curwin = curwin, *wp;
|
||||||
|
|
||||||
if (mouse_row >= 0 && mouse_col >= 0)
|
if (mouse_row >= 0 && mouse_col >= 0)
|
||||||
{
|
{
|
||||||
@@ -4637,7 +4637,10 @@ nv_mousescroll(cmdarg_T *cap)
|
|||||||
col = mouse_col;
|
col = mouse_col;
|
||||||
|
|
||||||
/* find the window at the pointer coordinates */
|
/* find the window at the pointer coordinates */
|
||||||
curwin = mouse_find_win(&row, &col);
|
wp = mouse_find_win(&row, &col);
|
||||||
|
if (wp == NULL)
|
||||||
|
return;
|
||||||
|
curwin = wp;
|
||||||
curbuf = curwin->w_buffer;
|
curbuf = curwin->w_buffer;
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
13
src/ui.c
13
src/ui.c
@@ -2709,6 +2709,8 @@ retnomove:
|
|||||||
#ifdef FEAT_WINDOWS
|
#ifdef FEAT_WINDOWS
|
||||||
/* find the window where the row is in */
|
/* find the window where the row is in */
|
||||||
wp = mouse_find_win(&row, &col);
|
wp = mouse_find_win(&row, &col);
|
||||||
|
if (wp == NULL)
|
||||||
|
return IN_UNKNOWN;
|
||||||
#else
|
#else
|
||||||
wp = firstwin;
|
wp = firstwin;
|
||||||
#endif
|
#endif
|
||||||
@@ -3117,11 +3119,13 @@ mouse_comp_pos(
|
|||||||
/*
|
/*
|
||||||
* Find the window at screen position "*rowp" and "*colp". The positions are
|
* Find the window at screen position "*rowp" and "*colp". The positions are
|
||||||
* updated to become relative to the top-left of the window.
|
* updated to become relative to the top-left of the window.
|
||||||
|
* Returns NULL when something is wrong.
|
||||||
*/
|
*/
|
||||||
win_T *
|
win_T *
|
||||||
mouse_find_win(int *rowp, int *colp UNUSED)
|
mouse_find_win(int *rowp, int *colp UNUSED)
|
||||||
{
|
{
|
||||||
frame_T *fp;
|
frame_T *fp;
|
||||||
|
win_T *wp;
|
||||||
|
|
||||||
fp = topframe;
|
fp = topframe;
|
||||||
*rowp -= firstwin->w_winrow;
|
*rowp -= firstwin->w_winrow;
|
||||||
@@ -3148,7 +3152,12 @@ mouse_find_win(int *rowp, int *colp UNUSED)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fp->fr_win;
|
/* When using a timer that closes a window the window might not actually
|
||||||
|
* exist. */
|
||||||
|
FOR_ALL_WINDOWS(wp)
|
||||||
|
if (wp == fp->fr_win)
|
||||||
|
return wp;
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -3171,6 +3180,8 @@ get_fpos_of_mouse(pos_T *mpos)
|
|||||||
#ifdef FEAT_WINDOWS
|
#ifdef FEAT_WINDOWS
|
||||||
/* find the window where the row is in */
|
/* find the window where the row is in */
|
||||||
wp = mouse_find_win(&row, &col);
|
wp = mouse_find_win(&row, &col);
|
||||||
|
if (wp == NULL)
|
||||||
|
return IN_UNKNOWN;
|
||||||
#else
|
#else
|
||||||
wp = firstwin;
|
wp = firstwin;
|
||||||
#endif
|
#endif
|
||||||
|
@@ -769,6 +769,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
948,
|
||||||
/**/
|
/**/
|
||||||
947,
|
947,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user