Mercurial > vim
comparison src/os_unix.c @ 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 | 186eebc31ec0 |
children | 4aea6c2f56a8 |
comparison
equal
deleted
inserted
replaced
15295:a8727dd4d239 | 15296:60e962106f8a |
---|---|
1669 { | 1669 { |
1670 got_x_error = TRUE; | 1670 got_x_error = TRUE; |
1671 return 0; | 1671 return 0; |
1672 } | 1672 } |
1673 | 1673 |
1674 /* | |
1675 * Return TRUE when connection to the X server is desired. | |
1676 */ | |
1677 static int | |
1678 x_connect_to_server(void) | |
1679 { | |
1680 // No point in connecting if we are exiting or dying. | |
1681 if (exiting || v_dying) | |
1682 return FALSE; | |
1683 | |
1684 #if defined(FEAT_CLIENTSERVER) | |
1685 if (x_force_connect) | |
1686 return TRUE; | |
1687 #endif | |
1688 if (x_no_connect) | |
1689 return FALSE; | |
1690 | |
1691 /* Check for a match with "exclude:" from 'clipboard'. */ | |
1692 if (clip_exclude_prog != NULL) | |
1693 { | |
1694 if (vim_regexec_prog(&clip_exclude_prog, FALSE, T_NAME, (colnr_T)0)) | |
1695 return FALSE; | |
1696 } | |
1697 return TRUE; | |
1698 } | |
1699 | |
1674 #if defined(FEAT_X11) && defined(FEAT_XCLIPBOARD) | 1700 #if defined(FEAT_X11) && defined(FEAT_XCLIPBOARD) |
1675 # if defined(HAVE_SETJMP_H) | 1701 # if defined(HAVE_SETJMP_H) |
1676 /* | 1702 /* |
1677 * An X IO Error handler, used to catch error while opening the display. | 1703 * An X IO Error handler, used to catch error while opening the display. |
1678 */ | 1704 */ |
1714 * (e.g. through tmux). | 1740 * (e.g. through tmux). |
1715 */ | 1741 */ |
1716 static void | 1742 static void |
1717 may_restore_clipboard(void) | 1743 may_restore_clipboard(void) |
1718 { | 1744 { |
1719 if (xterm_dpy_retry_count > 0) | 1745 // Only try restoring if we want the connection. |
1746 if (x_connect_to_server() && xterm_dpy_retry_count > 0) | |
1720 { | 1747 { |
1721 --xterm_dpy_retry_count; | 1748 --xterm_dpy_retry_count; |
1722 | 1749 |
1723 # ifndef LESSTIF_VERSION | 1750 # ifndef LESSTIF_VERSION |
1724 /* This has been reported to avoid Vim getting stuck. */ | 1751 /* This has been reported to avoid Vim getting stuck. */ |
1733 setup_term_clip(); | 1760 setup_term_clip(); |
1734 get_x11_title(FALSE); | 1761 get_x11_title(FALSE); |
1735 } | 1762 } |
1736 } | 1763 } |
1737 #endif | 1764 #endif |
1738 | |
1739 /* | |
1740 * Return TRUE when connection to the X server is desired. | |
1741 */ | |
1742 static int | |
1743 x_connect_to_server(void) | |
1744 { | |
1745 #if defined(FEAT_CLIENTSERVER) | |
1746 if (x_force_connect) | |
1747 return TRUE; | |
1748 #endif | |
1749 if (x_no_connect) | |
1750 return FALSE; | |
1751 | |
1752 /* Check for a match with "exclude:" from 'clipboard'. */ | |
1753 if (clip_exclude_prog != NULL) | |
1754 { | |
1755 if (vim_regexec_prog(&clip_exclude_prog, FALSE, T_NAME, (colnr_T)0)) | |
1756 return FALSE; | |
1757 } | |
1758 return TRUE; | |
1759 } | |
1760 | 1765 |
1761 /* | 1766 /* |
1762 * Test if "dpy" and x11_window are valid by getting the window title. | 1767 * Test if "dpy" and x11_window are valid by getting the window title. |
1763 * I don't actually want it yet, so there may be a simpler call to use, but | 1768 * I don't actually want it yet, so there may be a simpler call to use, but |
1764 * this will cause the error handler x_error_check() to be called if anything | 1769 * this will cause the error handler x_error_check() to be called if anything |