changeset 20382:361069b687d6 v8.2.0746

patch 8.2.0746: popup_clear() hangs when a popup can't be closed Commit: https://github.com/vim/vim/commit/d502aa4c10771ec8eb570345ec5e124c4a4b7cd0 Author: Bram Moolenaar <Bram@vim.org> Date: Wed May 13 01:04:32 2020 +0200 patch 8.2.0746: popup_clear() hangs when a popup can't be closed Problem: popup_clear() hangs when a popup can't be closed. Solution: Bail out when a popup can't be closed.
author Bram Moolenaar <Bram@vim.org>
date Wed, 13 May 2020 01:15:30 +0200
parents c89c37113e88
children 1ebebb9b62e7
files src/popupwin.c src/proto/popupwin.pro src/version.c
diffstat 3 files changed, 19 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -2531,8 +2531,9 @@ error_if_popup_window(int also_with_term
 /*
  * Close a popup window by Window-id.
  * Does not invoke the callback.
+ * Return OK if the popup was closed, FAIL otherwise.
  */
-    void
+    int
 popup_close(int id)
 {
     win_T	*wp;
@@ -2546,25 +2547,27 @@ popup_close(int id)
 	    if (wp == curwin)
 	    {
 		error_for_popup_window();
-		return;
+		return FAIL;
 	    }
 	    if (prev == NULL)
 		first_popupwin = wp->w_next;
 	    else
 		prev->w_next = wp->w_next;
 	    popup_free(wp);
-	    return;
+	    return OK;
 	}
 
     // go through tab-local popups
     FOR_ALL_TABPAGES(tp)
-	popup_close_tabpage(tp, id);
+	if (popup_close_tabpage(tp, id) == OK)
+	    return OK;
+    return FAIL;
 }
 
 /*
  * Close a popup window with Window-id "id" in tabpage "tp".
  */
-    void
+    int
 popup_close_tabpage(tabpage_T *tp, int id)
 {
     win_T	*wp;
@@ -2577,15 +2580,16 @@ popup_close_tabpage(tabpage_T *tp, int i
 	    if (wp == curwin)
 	    {
 		error_for_popup_window();
-		return;
+		return FAIL;
 	    }
 	    if (prev == NULL)
 		*root = wp->w_next;
 	    else
 		prev->w_next = wp->w_next;
 	    popup_free(wp);
-	    return;
+	    return OK;
 	}
+    return FAIL;
 }
 
     void
@@ -2594,9 +2598,11 @@ close_all_popups(void)
     if (ERROR_IF_ANY_POPUP_WINDOW)
 	return;
     while (first_popupwin != NULL)
-	popup_close(first_popupwin->w_id);
+	if (popup_close(first_popupwin->w_id) == FAIL)
+	    return;
     while (curtab->tp_first_popupwin != NULL)
-	popup_close(curtab->tp_first_popupwin->w_id);
+	if (popup_close(curtab->tp_first_popupwin->w_id) == FAIL)
+	    return;
 }
 
 /*
--- a/src/proto/popupwin.pro
+++ b/src/proto/popupwin.pro
@@ -34,8 +34,8 @@ void popup_show(win_T *wp);
 void f_popup_show(typval_T *argvars, typval_T *rettv);
 void f_popup_settext(typval_T *argvars, typval_T *rettv);
 int error_if_popup_window(int also_with_term);
-void popup_close(int id);
-void popup_close_tabpage(tabpage_T *tp, int id);
+int popup_close(int id);
+int popup_close_tabpage(tabpage_T *tp, int id);
 void close_all_popups(void);
 void f_popup_move(typval_T *argvars, typval_T *rettv);
 void f_popup_setoptions(typval_T *argvars, typval_T *rettv);
--- a/src/version.c
+++ b/src/version.c
@@ -747,6 +747,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    746,
+/**/
     745,
 /**/
     744,