cde0908
To: vim-dev@vim.org
cde0908
Subject: Patch 7.2.088 (extra)
cde0908
Fcc: outbox
cde0908
From: Bram Moolenaar <Bram@moolenaar.net>
cde0908
Mime-Version: 1.0
cde0908
Content-Type: text/plain; charset=ISO-8859-1
cde0908
Content-Transfer-Encoding: 8bit
cde0908
------------
cde0908
cde0908
Patch 7.2.088 (extra)
cde0908
Problem:    OpenClipboard() may fail when another application is using the
cde0908
	    clipboard.
cde0908
Solution:   Retry OpenClipboard() a few times. (Jianrong Yu)
cde0908
Files:	    src/os_mswin.c
cde0908
cde0908
cde0908
*** ../vim-7.2.087/src/os_mswin.c	Thu Nov 20 17:09:09 2008
cde0908
--- src/os_mswin.c	Thu Jan 22 18:38:12 2009
cde0908
***************
cde0908
*** 1224,1229 ****
cde0908
--- 1224,1248 ----
cde0908
  #endif /* FEAT_MBYTE */
cde0908
  
cde0908
  /*
cde0908
+  * Wait for another process to Close the Clipboard.
cde0908
+  * Returns TRUE for success.
cde0908
+  */
cde0908
+     int
cde0908
+ vim_open_clipboard()
cde0908
+ {
cde0908
+     int delay = 10;
cde0908
+ 
cde0908
+     while (!OpenClipboard(NULL))
cde0908
+     {
cde0908
+         if (delay > 500)
cde0908
+             return FALSE;  /* waited too long, give up */
cde0908
+         Sleep(delay);
cde0908
+         delay *= 2;	/* wait for 10, 20, 40, 80, etc. msec */
cde0908
+     }
cde0908
+     return TRUE;
cde0908
+ }
cde0908
+ 
cde0908
+ /*
cde0908
   * Get the current selection and put it in the clipboard register.
cde0908
   *
cde0908
   * NOTE: Must use GlobalLock/Unlock here to ensure Win32s compatibility.
cde0908
***************
cde0908
*** 1254,1260 ****
cde0908
       * Don't pass GetActiveWindow() as an argument to OpenClipboard() because
cde0908
       * then we can't paste back into the same window for some reason - webb.
cde0908
       */
cde0908
!     if (!OpenClipboard(NULL))
cde0908
  	return;
cde0908
  
cde0908
      /* Check for vim's own clipboard format first.  This only gets the type of
cde0908
--- 1273,1279 ----
cde0908
       * Don't pass GetActiveWindow() as an argument to OpenClipboard() because
cde0908
       * then we can't paste back into the same window for some reason - webb.
cde0908
       */
cde0908
!     if (!vim_open_clipboard())
cde0908
  	return;
cde0908
  
cde0908
      /* Check for vim's own clipboard format first.  This only gets the type of
cde0908
***************
cde0908
*** 1562,1568 ****
cde0908
       * because then we can't paste back into the same window for some
cde0908
       * reason - webb.
cde0908
       */
cde0908
!     if (OpenClipboard(NULL))
cde0908
      {
cde0908
  	if (EmptyClipboard())
cde0908
  	{
cde0908
--- 1581,1587 ----
cde0908
       * because then we can't paste back into the same window for some
cde0908
       * reason - webb.
cde0908
       */
cde0908
!     if (vim_open_clipboard())
cde0908
      {
cde0908
  	if (EmptyClipboard())
cde0908
  	{
cde0908
*** ../vim-7.2.087/src/version.c	Thu Jan 22 21:31:24 2009
cde0908
--- src/version.c	Thu Jan 22 21:47:52 2009
cde0908
***************
cde0908
*** 678,679 ****
cde0908
--- 678,681 ----
cde0908
  {   /* Add new patch number below this line */
cde0908
+ /**/
cde0908
+     88,
cde0908
  /**/
cde0908
cde0908
-- 
cde0908
hundred-and-one symptoms of being an internet addict:
cde0908
22. You've already visited all the links at Yahoo and you're halfway through
cde0908
    Lycos.
cde0908
cde0908
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
cde0908
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
cde0908
\\\        download, build and distribute -- http://www.A-A-P.org        ///
cde0908
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///