changeset 15296:60e962106f8a v8.1.0656

patch 8.1.0656: trying to reconnect to X server may cause problems commit https://github.com/vim/vim/commit/c0c7549687b8d095f3ab7e99c8e0bfaaf63b57d4 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Dec 29 11:03:23 2018 +0100 patch 8.1.0656: trying to reconnect to X server may cause problems Problem: Trying to reconnect to X server may cause problems. Solution: Do no try reconnecting when exiting. (James McCoy)
author Bram Moolenaar <Bram@vim.org>
date Sat, 29 Dec 2018 11:15:05 +0100
parents a8727dd4d239
children 137d5ee732e0
files src/os_unix.c src/version.c
diffstat 2 files changed, 30 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -1671,6 +1671,32 @@ x_error_check(Display *dpy UNUSED, XErro
     return 0;
 }
 
+/*
+ * Return TRUE when connection to the X server is desired.
+ */
+    static int
+x_connect_to_server(void)
+{
+    // No point in connecting if we are exiting or dying.
+    if (exiting || v_dying)
+	return FALSE;
+
+#if defined(FEAT_CLIENTSERVER)
+    if (x_force_connect)
+	return TRUE;
+#endif
+    if (x_no_connect)
+	return FALSE;
+
+    /* Check for a match with "exclude:" from 'clipboard'. */
+    if (clip_exclude_prog != NULL)
+    {
+	if (vim_regexec_prog(&clip_exclude_prog, FALSE, T_NAME, (colnr_T)0))
+	    return FALSE;
+    }
+    return TRUE;
+}
+
 #if defined(FEAT_X11) && defined(FEAT_XCLIPBOARD)
 # if defined(HAVE_SETJMP_H)
 /*
@@ -1716,7 +1742,8 @@ x_IOerror_handler(Display *dpy UNUSED)
     static void
 may_restore_clipboard(void)
 {
-    if (xterm_dpy_retry_count > 0)
+    // Only try restoring if we want the connection.
+    if (x_connect_to_server() && xterm_dpy_retry_count > 0)
     {
 	--xterm_dpy_retry_count;
 
@@ -1737,28 +1764,6 @@ may_restore_clipboard(void)
 #endif
 
 /*
- * Return TRUE when connection to the X server is desired.
- */
-    static int
-x_connect_to_server(void)
-{
-#if defined(FEAT_CLIENTSERVER)
-    if (x_force_connect)
-	return TRUE;
-#endif
-    if (x_no_connect)
-	return FALSE;
-
-    /* Check for a match with "exclude:" from 'clipboard'. */
-    if (clip_exclude_prog != NULL)
-    {
-	if (vim_regexec_prog(&clip_exclude_prog, FALSE, T_NAME, (colnr_T)0))
-	    return FALSE;
-    }
-    return TRUE;
-}
-
-/*
  * Test if "dpy" and x11_window are valid by getting the window title.
  * I don't actually want it yet, so there may be a simpler call to use, but
  * this will cause the error handler x_error_check() to be called if anything
--- a/src/version.c
+++ b/src/version.c
@@ -800,6 +800,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    656,
+/**/
     655,
 /**/
     654,