Mercurial > vim
comparison src/ui.c @ 12136:60cf03e59402 v8.0.0948
patch 8.0.0948: crash if timer closes window while dragging status line
commit https://github.com/vim/vim/commit/989a70c590c2bd109eb362d3a0e48cb1427ae13d
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Aug 16 22:46:01 2017 +0200
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)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Wed, 16 Aug 2017 23:00:05 +0200 |
parents | ca4931a20f8c |
children | 040a892d0eed |
comparison
equal
deleted
inserted
replaced
12135:a4f1b795227c | 12136:60cf03e59402 |
---|---|
2707 return IN_UNKNOWN; | 2707 return IN_UNKNOWN; |
2708 | 2708 |
2709 #ifdef FEAT_WINDOWS | 2709 #ifdef FEAT_WINDOWS |
2710 /* find the window where the row is in */ | 2710 /* find the window where the row is in */ |
2711 wp = mouse_find_win(&row, &col); | 2711 wp = mouse_find_win(&row, &col); |
2712 if (wp == NULL) | |
2713 return IN_UNKNOWN; | |
2712 #else | 2714 #else |
2713 wp = firstwin; | 2715 wp = firstwin; |
2714 #endif | 2716 #endif |
2715 dragwin = NULL; | 2717 dragwin = NULL; |
2716 /* | 2718 /* |
3115 | 3117 |
3116 #if defined(FEAT_WINDOWS) || defined(PROTO) | 3118 #if defined(FEAT_WINDOWS) || defined(PROTO) |
3117 /* | 3119 /* |
3118 * Find the window at screen position "*rowp" and "*colp". The positions are | 3120 * Find the window at screen position "*rowp" and "*colp". The positions are |
3119 * updated to become relative to the top-left of the window. | 3121 * updated to become relative to the top-left of the window. |
3122 * Returns NULL when something is wrong. | |
3120 */ | 3123 */ |
3121 win_T * | 3124 win_T * |
3122 mouse_find_win(int *rowp, int *colp UNUSED) | 3125 mouse_find_win(int *rowp, int *colp UNUSED) |
3123 { | 3126 { |
3124 frame_T *fp; | 3127 frame_T *fp; |
3128 win_T *wp; | |
3125 | 3129 |
3126 fp = topframe; | 3130 fp = topframe; |
3127 *rowp -= firstwin->w_winrow; | 3131 *rowp -= firstwin->w_winrow; |
3128 for (;;) | 3132 for (;;) |
3129 { | 3133 { |
3146 break; | 3150 break; |
3147 *rowp -= fp->fr_height; | 3151 *rowp -= fp->fr_height; |
3148 } | 3152 } |
3149 } | 3153 } |
3150 } | 3154 } |
3151 return fp->fr_win; | 3155 /* When using a timer that closes a window the window might not actually |
3156 * exist. */ | |
3157 FOR_ALL_WINDOWS(wp) | |
3158 if (wp == fp->fr_win) | |
3159 return wp; | |
3160 return NULL; | |
3152 } | 3161 } |
3153 #endif | 3162 #endif |
3154 | 3163 |
3155 #if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_MAC) \ | 3164 #if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_MAC) \ |
3156 || defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_MSWIN) \ | 3165 || defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_MSWIN) \ |
3169 return IN_UNKNOWN; | 3178 return IN_UNKNOWN; |
3170 | 3179 |
3171 #ifdef FEAT_WINDOWS | 3180 #ifdef FEAT_WINDOWS |
3172 /* find the window where the row is in */ | 3181 /* find the window where the row is in */ |
3173 wp = mouse_find_win(&row, &col); | 3182 wp = mouse_find_win(&row, &col); |
3183 if (wp == NULL) | |
3184 return IN_UNKNOWN; | |
3174 #else | 3185 #else |
3175 wp = firstwin; | 3186 wp = firstwin; |
3176 #endif | 3187 #endif |
3177 /* | 3188 /* |
3178 * winpos and height may change in win_enter()! | 3189 * winpos and height may change in win_enter()! |