New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ドラッグ中にバッファが消えるとクラッシュする #1071

Closed
mattn opened this Issue Aug 16, 2017 · 5 comments

Comments

Projects
None yet
3 participants
@mattn
Member

mattn commented Aug 16, 2017

バージョン 8.0.946

function! s:bwipe(...)
  bwipe!
endfunction

new
call timer_start(5000, function('s:bwipe'))

これを実行して5秒間分割バーをドラッグし続けると落ちる。

@tyru

This comment has been minimized.

Show comment
Hide comment
@tyru
Member

tyru commented Aug 16, 2017

@mattn

This comment has been minimized.

Show comment
Hide comment
@mattn

mattn Aug 16, 2017

Member
diff --git a/src/window.c b/src/window.c
index 311009837..436e9a368 100644
--- a/src/window.c
+++ b/src/window.c
@@ -5504,7 +5504,17 @@ win_drag_status_line(win_T *dragwin, int offset)
     int		row;
     int		up;	/* if TRUE, drag status line up, otherwise down */
     int		n;
+    win_T	*wp;
+    int		found = FALSE;
 
+    FOR_ALL_WINDOWS(wp)
+	if (wp == dragwin)
+	{
+	    found = TRUE;
+	    break;
+	}
+    if (!found)
+	return;
     fr = dragwin->w_frame;
     curfr = fr;
     if (fr != topframe)		/* more than one window */

これで治るのを確認しました。ただこれはこの関数に入る前の mouse_find_win で NULL を返した方がエレガントかも。

Member

mattn commented Aug 16, 2017

diff --git a/src/window.c b/src/window.c
index 311009837..436e9a368 100644
--- a/src/window.c
+++ b/src/window.c
@@ -5504,7 +5504,17 @@ win_drag_status_line(win_T *dragwin, int offset)
     int		row;
     int		up;	/* if TRUE, drag status line up, otherwise down */
     int		n;
+    win_T	*wp;
+    int		found = FALSE;
 
+    FOR_ALL_WINDOWS(wp)
+	if (wp == dragwin)
+	{
+	    found = TRUE;
+	    break;
+	}
+    if (!found)
+	return;
     fr = dragwin->w_frame;
     curfr = fr;
     if (fr != topframe)		/* more than one window */

これで治るのを確認しました。ただこれはこの関数に入る前の mouse_find_win で NULL を返した方がエレガントかも。

@mattn

This comment has been minimized.

Show comment
Hide comment
@mattn

mattn Aug 16, 2017

Member
diff --git a/src/edit.c b/src/edit.c
index e08370863..3a9b3aaf9 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -9418,7 +9418,7 @@ ins_mousescroll(int dir)
 {
     pos_T	tpos;
 # if defined(FEAT_WINDOWS)
-    win_T	*old_curwin = curwin;
+    win_T	*old_curwin = curwin, *wp;
 # endif
 # ifdef FEAT_INS_EXPAND
     int		did_scroll = FALSE;
@@ -9435,7 +9435,10 @@ ins_mousescroll(int dir)
 	col = mouse_col;
 
 	/* 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;
     }
     if (curwin == old_curwin)
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 2be7fe1bf..452183594 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -4382,6 +4382,8 @@ f_getchar(typval_T *argvars, typval_T *rettv)
 		/* Find the window at the mouse coordinates and compute the
 		 * text position. */
 		win = mouse_find_win(&row, &col);
+		if (win == NULL)
+		    return;
 		(void)mouse_comp_pos(win, &row, &col, &lnum);
 # ifdef FEAT_WINDOWS
 		for (wp = firstwin; wp != win; wp = wp->w_next)
diff --git a/src/gui.c b/src/gui.c
index 63625bfc4..431011fd1 100644
--- a/src/gui.c
+++ b/src/gui.c
@@ -4948,6 +4948,8 @@ xy2win(int x UNUSED, int y UNUSED)
     if (row < 0 || col < 0)		/* before first window */
 	return NULL;
     wp = mouse_find_win(&row, &col);
+    if (wp == NULL)
+	return NULL;
 # ifdef FEAT_MOUSESHAPE
     if (State == HITRETURN || State == ASKMORE)
     {
diff --git a/src/normal.c b/src/normal.c
index 24ab06ddf..fb0706ebf 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -4621,7 +4621,7 @@ nv_screengo(oparg_T *oap, int dir, long dist)
 nv_mousescroll(cmdarg_T *cap)
 {
 # ifdef FEAT_WINDOWS
-    win_T *old_curwin = curwin;
+    win_T *old_curwin = curwin, *wp;
 
     if (mouse_row >= 0 && mouse_col >= 0)
     {
@@ -4631,7 +4631,10 @@ nv_mousescroll(cmdarg_T *cap)
 	col = mouse_col;
 
 	/* 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;
     }
 # endif
diff --git a/src/ui.c b/src/ui.c
index 907390e6b..8277acad5 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -2709,6 +2709,8 @@ retnomove:
 #ifdef FEAT_WINDOWS
 	/* find the window where the row is in */
 	wp = mouse_find_win(&row, &col);
+	if (wp == NULL)
+	    return IN_UNKNOWN;
 #else
 	wp = firstwin;
 #endif
@@ -3122,6 +3124,7 @@ mouse_comp_pos(
 mouse_find_win(int *rowp, int *colp UNUSED)
 {
     frame_T	*fp;
+    win_T	*wp;
 
     fp = topframe;
     *rowp -= firstwin->w_winrow;
@@ -3148,7 +3151,10 @@ mouse_find_win(int *rowp, int *colp UNUSED)
 	    }
 	}
     }
-    return fp->fr_win;
+    FOR_ALL_WINDOWS(wp)
+	if (wp == fp->fr_win)
+	    return wp;
+    return NULL;
 }
 #endif
 
@@ -3171,6 +3177,8 @@ get_fpos_of_mouse(pos_T *mpos)
 #ifdef FEAT_WINDOWS
     /* find the window where the row is in */
     wp = mouse_find_win(&row, &col);
+    if (wp == NULL)
+	return IN_UNKNOWN;
 #else
     wp = firstwin;
 #endif

思ったより量多かった。

Member

mattn commented Aug 16, 2017

diff --git a/src/edit.c b/src/edit.c
index e08370863..3a9b3aaf9 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -9418,7 +9418,7 @@ ins_mousescroll(int dir)
 {
     pos_T	tpos;
 # if defined(FEAT_WINDOWS)
-    win_T	*old_curwin = curwin;
+    win_T	*old_curwin = curwin, *wp;
 # endif
 # ifdef FEAT_INS_EXPAND
     int		did_scroll = FALSE;
@@ -9435,7 +9435,10 @@ ins_mousescroll(int dir)
 	col = mouse_col;
 
 	/* 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;
     }
     if (curwin == old_curwin)
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 2be7fe1bf..452183594 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -4382,6 +4382,8 @@ f_getchar(typval_T *argvars, typval_T *rettv)
 		/* Find the window at the mouse coordinates and compute the
 		 * text position. */
 		win = mouse_find_win(&row, &col);
+		if (win == NULL)
+		    return;
 		(void)mouse_comp_pos(win, &row, &col, &lnum);
 # ifdef FEAT_WINDOWS
 		for (wp = firstwin; wp != win; wp = wp->w_next)
diff --git a/src/gui.c b/src/gui.c
index 63625bfc4..431011fd1 100644
--- a/src/gui.c
+++ b/src/gui.c
@@ -4948,6 +4948,8 @@ xy2win(int x UNUSED, int y UNUSED)
     if (row < 0 || col < 0)		/* before first window */
 	return NULL;
     wp = mouse_find_win(&row, &col);
+    if (wp == NULL)
+	return NULL;
 # ifdef FEAT_MOUSESHAPE
     if (State == HITRETURN || State == ASKMORE)
     {
diff --git a/src/normal.c b/src/normal.c
index 24ab06ddf..fb0706ebf 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -4621,7 +4621,7 @@ nv_screengo(oparg_T *oap, int dir, long dist)
 nv_mousescroll(cmdarg_T *cap)
 {
 # ifdef FEAT_WINDOWS
-    win_T *old_curwin = curwin;
+    win_T *old_curwin = curwin, *wp;
 
     if (mouse_row >= 0 && mouse_col >= 0)
     {
@@ -4631,7 +4631,10 @@ nv_mousescroll(cmdarg_T *cap)
 	col = mouse_col;
 
 	/* 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;
     }
 # endif
diff --git a/src/ui.c b/src/ui.c
index 907390e6b..8277acad5 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -2709,6 +2709,8 @@ retnomove:
 #ifdef FEAT_WINDOWS
 	/* find the window where the row is in */
 	wp = mouse_find_win(&row, &col);
+	if (wp == NULL)
+	    return IN_UNKNOWN;
 #else
 	wp = firstwin;
 #endif
@@ -3122,6 +3124,7 @@ mouse_comp_pos(
 mouse_find_win(int *rowp, int *colp UNUSED)
 {
     frame_T	*fp;
+    win_T	*wp;
 
     fp = topframe;
     *rowp -= firstwin->w_winrow;
@@ -3148,7 +3151,10 @@ mouse_find_win(int *rowp, int *colp UNUSED)
 	    }
 	}
     }
-    return fp->fr_win;
+    FOR_ALL_WINDOWS(wp)
+	if (wp == fp->fr_win)
+	    return wp;
+    return NULL;
 }
 #endif
 
@@ -3171,6 +3177,8 @@ get_fpos_of_mouse(pos_T *mpos)
 #ifdef FEAT_WINDOWS
     /* find the window where the row is in */
     wp = mouse_find_win(&row, &col);
+    if (wp == NULL)
+	return IN_UNKNOWN;
 #else
     wp = firstwin;
 #endif

思ったより量多かった。

@mattn

This comment has been minimized.

Show comment
Hide comment
@mattn
Member

mattn commented Aug 16, 2017

@h-east

This comment has been minimized.

Show comment
Hide comment
@h-east
Member

h-east commented Aug 17, 2017

8.0.0948
vim/vim@989a70c

@h-east h-east closed this Aug 17, 2017

@h-east h-east added the xlose/fixed label Aug 17, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment