Karsten Hopp 02a447
To: vim_dev@googlegroups.com
Karsten Hopp 02a447
Subject: Patch 7.4.886
Karsten Hopp 02a447
Fcc: outbox
Karsten Hopp 02a447
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 02a447
Mime-Version: 1.0
Karsten Hopp 02a447
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 02a447
Content-Transfer-Encoding: 8bit
Karsten Hopp 02a447
------------
Karsten Hopp 02a447
Karsten Hopp 02a447
Patch 7.4.886 (after 7.4.876)
Karsten Hopp 02a447
Problem:    Windows7: Switching screen buffer causes flicker when using
Karsten Hopp 02a447
            system().
Karsten Hopp 02a447
Solution:   Instead of actually switching screen buffer, duplicate the handle.
Karsten Hopp 02a447
            (Yasuhiro Matsumoto)
Karsten Hopp 02a447
Files:      src/os_win32.c
Karsten Hopp 02a447
Karsten Hopp 02a447
Karsten Hopp 02a447
*** ../vim-7.4.885/src/os_win32.c	2015-09-25 15:28:32.740126079 +0200
Karsten Hopp 02a447
--- src/os_win32.c	2015-09-29 13:59:59.648635163 +0200
Karsten Hopp 02a447
***************
Karsten Hopp 02a447
*** 4612,4631 ****
Karsten Hopp 02a447
  mch_system(char *cmd, int options)
Karsten Hopp 02a447
  {
Karsten Hopp 02a447
      int ret;
Karsten Hopp 02a447
  
Karsten Hopp 02a447
      /*
Karsten Hopp 02a447
!      * Restore non-termcap screen buffer before execute external program, and
Karsten Hopp 02a447
!      * revert it after.  Because msys and msys2's programs will cause freeze
Karsten Hopp 02a447
!      * or crash conhost.exe (Windows's console window provider) and vim.exe,
Karsten Hopp 02a447
!      * if active screen buffer is vim's one on Windows7.
Karsten Hopp 02a447
       */
Karsten Hopp 02a447
!     if (is_win7 && g_fTermcapMode)
Karsten Hopp 02a447
! 	SetConsoleActiveScreenBuffer(g_cbNonTermcap.handle);
Karsten Hopp 02a447
  
Karsten Hopp 02a447
      ret = mch_system1(cmd, options);
Karsten Hopp 02a447
  
Karsten Hopp 02a447
!     if (is_win7 && g_fTermcapMode)
Karsten Hopp 02a447
! 	SetConsoleActiveScreenBuffer(g_cbTermcap.handle);
Karsten Hopp 02a447
  
Karsten Hopp 02a447
      return ret;
Karsten Hopp 02a447
  }
Karsten Hopp 02a447
--- 4612,4645 ----
Karsten Hopp 02a447
  mch_system(char *cmd, int options)
Karsten Hopp 02a447
  {
Karsten Hopp 02a447
      int ret;
Karsten Hopp 02a447
+     HANDLE hTemp = INVALID_HANDLE_VALUE;
Karsten Hopp 02a447
  
Karsten Hopp 02a447
      /*
Karsten Hopp 02a447
!      * Call DuplicateHandle before executing an external program, because msys
Karsten Hopp 02a447
!      * and msys2's programs will call CreateConsoleScreenBuffer and
Karsten Hopp 02a447
!      * CloseHandle.  CreateConsoleScreenBuffer returns the same handle which
Karsten Hopp 02a447
!      * created by vim.  This causes a crash. This workaround is required on
Karsten Hopp 02a447
!      * Windows7.
Karsten Hopp 02a447
       */
Karsten Hopp 02a447
!     if (is_win7
Karsten Hopp 02a447
! 	    && g_fTermcapMode
Karsten Hopp 02a447
! 	    && DuplicateHandle(
Karsten Hopp 02a447
! 		    GetCurrentProcess(),
Karsten Hopp 02a447
! 		    g_hConOut,
Karsten Hopp 02a447
! 		    GetCurrentProcess(),
Karsten Hopp 02a447
! 		    &hTemp,
Karsten Hopp 02a447
! 		    0,
Karsten Hopp 02a447
! 		    TRUE,
Karsten Hopp 02a447
! 		    DUPLICATE_SAME_ACCESS))
Karsten Hopp 02a447
! 	SetConsoleActiveScreenBuffer(hTemp);
Karsten Hopp 02a447
  
Karsten Hopp 02a447
      ret = mch_system1(cmd, options);
Karsten Hopp 02a447
  
Karsten Hopp 02a447
!     if (hTemp != INVALID_HANDLE_VALUE)
Karsten Hopp 02a447
!     {
Karsten Hopp 02a447
! 	SetConsoleActiveScreenBuffer(g_hConOut);
Karsten Hopp 02a447
! 	CloseHandle(hTemp);
Karsten Hopp 02a447
!     }
Karsten Hopp 02a447
  
Karsten Hopp 02a447
      return ret;
Karsten Hopp 02a447
  }
Karsten Hopp 02a447
*** ../vim-7.4.885/src/version.c	2015-09-29 12:08:39.333321460 +0200
Karsten Hopp 02a447
--- src/version.c	2015-09-29 13:56:54.234534337 +0200
Karsten Hopp 02a447
***************
Karsten Hopp 02a447
*** 743,744 ****
Karsten Hopp 02a447
--- 743,746 ----
Karsten Hopp 02a447
  {   /* Add new patch number below this line */
Karsten Hopp 02a447
+ /**/
Karsten Hopp 02a447
+     886,
Karsten Hopp 02a447
  /**/
Karsten Hopp 02a447
Karsten Hopp 02a447
-- 
Karsten Hopp 02a447
Anyone who is capable of getting themselves made President should on no
Karsten Hopp 02a447
account be allowed to do the job.
Karsten Hopp 02a447
		-- Douglas Adams, "The Hitchhiker's Guide to the Galaxy"
Karsten Hopp 02a447
Karsten Hopp 02a447
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 02a447
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 02a447
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 02a447
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///