To: vim_dev@googlegroups.com Subject: Patch 8.0.0948 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.0948 Problem: Crash if timer closes window while dragging status line. Solution: Check if the window still exists. (Yasuhiro Matsumoto, closes #1979) Files: src/edit.c, src/evalfunc.c, src/gui.c, src/normal.c, src/ui.c *** ../vim-8.0.0947/src/edit.c 2017-06-29 22:33:07.007322558 +0200 --- src/edit.c 2017-08-16 22:38:06.972645393 +0200 *************** *** 9418,9424 **** { pos_T tpos; # if defined(FEAT_WINDOWS) ! win_T *old_curwin = curwin; # endif # ifdef FEAT_INS_EXPAND int did_scroll = FALSE; --- 9418,9424 ---- { pos_T tpos; # if defined(FEAT_WINDOWS) ! win_T *old_curwin = curwin, *wp; # endif # ifdef FEAT_INS_EXPAND int did_scroll = FALSE; *************** *** 9435,9441 **** col = mouse_col; /* find the window at the pointer coordinates */ ! curwin = mouse_find_win(&row, &col); curbuf = curwin->w_buffer; } if (curwin == old_curwin) --- 9435,9444 ---- col = mouse_col; /* find the window at the pointer coordinates */ ! wp = mouse_find_win(&row, &col); ! if (wp == NULL) ! return; ! curwin = wp; curbuf = curwin->w_buffer; } if (curwin == old_curwin) *** ../vim-8.0.0947/src/evalfunc.c 2017-08-13 20:58:29.280457584 +0200 --- src/evalfunc.c 2017-08-16 22:38:06.980645343 +0200 *************** *** 4382,4387 **** --- 4382,4389 ---- /* 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) *** ../vim-8.0.0947/src/gui.c 2017-08-12 22:55:54.217280907 +0200 --- src/gui.c 2017-08-16 22:44:43.866148403 +0200 *************** *** 4933,4939 **** } /* ! * Find window where the mouse pointer "y" coordinate is in. */ static win_T * xy2win(int x UNUSED, int y UNUSED) --- 4933,4939 ---- } /* ! * Find window where the mouse pointer "x" / "y" coordinate is in. */ static win_T * xy2win(int x UNUSED, int y UNUSED) *************** *** 4948,4953 **** --- 4948,4955 ---- 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) { *** ../vim-8.0.0947/src/normal.c 2017-08-16 21:07:19.870207115 +0200 --- src/normal.c 2017-08-16 22:38:06.984645319 +0200 *************** *** 4627,4633 **** nv_mousescroll(cmdarg_T *cap) { # ifdef FEAT_WINDOWS ! win_T *old_curwin = curwin; if (mouse_row >= 0 && mouse_col >= 0) { --- 4627,4633 ---- nv_mousescroll(cmdarg_T *cap) { # ifdef FEAT_WINDOWS ! win_T *old_curwin = curwin, *wp; if (mouse_row >= 0 && mouse_col >= 0) { *************** *** 4637,4643 **** col = mouse_col; /* find the window at the pointer coordinates */ ! curwin = mouse_find_win(&row, &col); curbuf = curwin->w_buffer; } # endif --- 4637,4646 ---- col = mouse_col; /* find the window at the pointer coordinates */ ! wp = mouse_find_win(&row, &col); ! if (wp == NULL) ! return; ! curwin = wp; curbuf = curwin->w_buffer; } # endif *** ../vim-8.0.0947/src/ui.c 2017-08-12 19:51:37.815214191 +0200 --- src/ui.c 2017-08-16 22:41:53.823218733 +0200 *************** *** 2709,2714 **** --- 2709,2716 ---- #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 *************** *** 3117,3127 **** --- 3119,3131 ---- /* * Find the window at screen position "*rowp" and "*colp". The positions are * updated to become relative to the top-left of the window. + * Returns NULL when something is wrong. */ win_T * mouse_find_win(int *rowp, int *colp UNUSED) { frame_T *fp; + win_T *wp; fp = topframe; *rowp -= firstwin->w_winrow; *************** *** 3148,3154 **** } } } ! return fp->fr_win; } #endif --- 3152,3163 ---- } } } ! /* 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 *************** *** 3171,3176 **** --- 3180,3187 ---- #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 *** ../vim-8.0.0947/src/version.c 2017-08-16 21:07:19.874207089 +0200 --- src/version.c 2017-08-16 22:39:33.432103126 +0200 *************** *** 771,772 **** --- 771,774 ---- { /* Add new patch number below this line */ + /**/ + 948, /**/ -- Clothes make the man. Naked people have little or no influence on society. -- Mark Twain (Samuel Clemens) (1835-1910) /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///