summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2015-09-29 14:01:12 +0200
committerBram Moolenaar <Bram@vim.org>2015-09-29 14:01:12 +0200
commit1d478a6242871dcf4566814d3c6208df17991426 (patch)
tree9f87420714b8d4c6e0b2d280cc87f664d30350a5
parentc79a5452acd695238798947e40086f9823c400e7 (diff)
patch 7.4.886v7.4.886
Problem: Windows7: Switching screen buffer causes flicker when using system(). Solution: Instead of actually switching screen buffer, duplicate the handle. (Yasuhiro Matsumoto)
-rw-r--r--src/os_win32.c30
-rw-r--r--src/version.c2
2 files changed, 24 insertions, 8 deletions
diff --git a/src/os_win32.c b/src/os_win32.c
index 6981d2f31c..5114863fae 100644
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -4612,20 +4612,34 @@ mch_system1(char *cmd, int options)
mch_system(char *cmd, int options)
{
int ret;
+ HANDLE hTemp = INVALID_HANDLE_VALUE;
/*
- * Restore non-termcap screen buffer before execute external program, and
- * revert it after. Because msys and msys2's programs will cause freeze
- * or crash conhost.exe (Windows's console window provider) and vim.exe,
- * if active screen buffer is vim's one on Windows7.
+ * Call DuplicateHandle before executing an external program, because msys
+ * and msys2's programs will call CreateConsoleScreenBuffer and
+ * CloseHandle. CreateConsoleScreenBuffer returns the same handle which
+ * created by vim. This causes a crash. This workaround is required on
+ * Windows7.
*/
- if (is_win7 && g_fTermcapMode)
- SetConsoleActiveScreenBuffer(g_cbNonTermcap.handle);
+ if (is_win7
+ && g_fTermcapMode
+ && DuplicateHandle(
+ GetCurrentProcess(),
+ g_hConOut,
+ GetCurrentProcess(),
+ &hTemp,
+ 0,
+ TRUE,
+ DUPLICATE_SAME_ACCESS))
+ SetConsoleActiveScreenBuffer(hTemp);
ret = mch_system1(cmd, options);
- if (is_win7 && g_fTermcapMode)
- SetConsoleActiveScreenBuffer(g_cbTermcap.handle);
+ if (hTemp != INVALID_HANDLE_VALUE)
+ {
+ SetConsoleActiveScreenBuffer(g_hConOut);
+ CloseHandle(hTemp);
+ }
return ret;
}
diff --git a/src/version.c b/src/version.c
index f31f1bd1cb..51602989d9 100644
--- a/src/version.c
+++ b/src/version.c
@@ -742,6 +742,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 886,
+/**/
885,
/**/
884,