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