Mercurial > vim
comparison src/quickfix.c @ 14956:940def6df43f v8.1.0489
patch 8.1.0489: crash when autocmd clears vimpgrep location list
commit https://github.com/vim/vim/commit/b6f1480a6a8b1a6fa4d5da97aeb5f4755b71eb91
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Oct 21 18:47:43 2018 +0200
patch 8.1.0489: crash when autocmd clears vimpgrep location list
Problem: Crash when autocmd clears vimpgrep location list.
Solution: Return from qf_jump_edit_buffer() early. (Yegappan Lakshmanan)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 21 Oct 2018 19:00:07 +0200 |
parents | 69d2749a6a2f |
children | 676db1b7fc35 |
comparison
equal
deleted
inserted
replaced
14955:9a25c06e8803 | 14956:940def6df43f |
---|---|
2983 win_T *oldwin, | 2983 win_T *oldwin, |
2984 int *opened_window) | 2984 int *opened_window) |
2985 { | 2985 { |
2986 qf_list_T *qfl = &qi->qf_lists[qi->qf_curlist]; | 2986 qf_list_T *qfl = &qi->qf_lists[qi->qf_curlist]; |
2987 int retval = OK; | 2987 int retval = OK; |
2988 int old_qf_curlist = qi->qf_curlist; | |
2989 int save_qfid = qfl->qf_id; | |
2988 | 2990 |
2989 if (qf_ptr->qf_type == 1) | 2991 if (qf_ptr->qf_type == 1) |
2990 { | 2992 { |
2991 // Open help file (do_ecmd() will set b_help flag, readfile() will | 2993 // Open help file (do_ecmd() will set b_help flag, readfile() will |
2992 // set b_p_ro flag). | 2994 // set b_p_ro flag). |
2993 if (!can_abandon(curbuf, forceit)) | 2995 if (!can_abandon(curbuf, forceit)) |
2994 { | 2996 { |
2995 no_write_message(); | 2997 no_write_message(); |
2996 retval = FAIL; | 2998 return FAIL; |
2997 } | 2999 } |
2998 else | 3000 |
2999 retval = do_ecmd(qf_ptr->qf_fnum, NULL, NULL, NULL, (linenr_T)1, | 3001 retval = do_ecmd(qf_ptr->qf_fnum, NULL, NULL, NULL, (linenr_T)1, |
3000 ECMD_HIDE + ECMD_SET_HELP, | 3002 ECMD_HIDE + ECMD_SET_HELP, |
3001 oldwin == curwin ? curwin : NULL); | 3003 oldwin == curwin ? curwin : NULL); |
3002 } | 3004 } |
3003 else | 3005 else |
3004 { | |
3005 int old_qf_curlist = qi->qf_curlist; | |
3006 int save_qfid = qfl->qf_id; | |
3007 | |
3008 retval = buflist_getfile(qf_ptr->qf_fnum, | 3006 retval = buflist_getfile(qf_ptr->qf_fnum, |
3009 (linenr_T)1, GETF_SETMARK | GETF_SWITCH, forceit); | 3007 (linenr_T)1, GETF_SETMARK | GETF_SWITCH, forceit); |
3010 | 3008 |
3011 if (IS_LL_STACK(qi)) | 3009 // If a location list, check whether the associated window is still |
3012 { | 3010 // present. |
3013 // Location list. Check whether the associated window is still | 3011 if (IS_LL_STACK(qi) && !win_valid_any_tab(oldwin)) |
3014 // present and the list is still valid. | 3012 { |
3015 if (!win_valid_any_tab(oldwin)) | 3013 EMSG(_("E924: Current window was closed")); |
3016 { | 3014 *opened_window = FALSE; |
3017 EMSG(_("E924: Current window was closed")); | 3015 return NOTDONE; |
3018 *opened_window = FALSE; | 3016 } |
3019 return NOTDONE; | 3017 |
3020 } | 3018 if (IS_QF_STACK(qi) && !qflist_valid(NULL, save_qfid)) |
3021 else if (!qflist_valid(oldwin, save_qfid)) | 3019 { |
3022 { | 3020 EMSG(_("E925: Current quickfix was changed")); |
3023 EMSG(_(e_loc_list_changed)); | 3021 return NOTDONE; |
3024 return NOTDONE; | 3022 } |
3025 } | 3023 |
3026 } | 3024 if (old_qf_curlist != qi->qf_curlist |
3027 else if (old_qf_curlist != qi->qf_curlist | 3025 || !is_qf_entry_present(qfl, qf_ptr)) |
3028 || !is_qf_entry_present(qfl, qf_ptr)) | 3026 { |
3029 { | 3027 if (IS_QF_STACK(qi)) |
3030 if (IS_QF_STACK(qi)) | 3028 EMSG(_("E925: Current quickfix was changed")); |
3031 EMSG(_("E925: Current quickfix was changed")); | 3029 else |
3032 else | 3030 EMSG(_(e_loc_list_changed)); |
3033 EMSG(_(e_loc_list_changed)); | 3031 return NOTDONE; |
3034 return NOTDONE; | |
3035 } | |
3036 } | 3032 } |
3037 | 3033 |
3038 return retval; | 3034 return retval; |
3039 } | 3035 } |
3040 | 3036 |