]> git.eshelyaron.com Git - emacs.git/commitdiff
(Fw32_set_clipboard_data): Get sequence number after closing the clipboard.
authorJason Rumney <jasonr@gnu.org>
Sun, 18 Apr 2004 18:34:03 +0000 (18:34 +0000)
committerJason Rumney <jasonr@gnu.org>
Sun, 18 Apr 2004 18:34:03 +0000 (18:34 +0000)
src/w32select.c

index 940cce35772ff48b5a5cf1a7b2828af5ba32faf5..0c8849c7be6fe35a2b7cf64f55a4f4b4b813333b 100644 (file)
@@ -259,11 +259,18 @@ DEFUN ("w32-set-clipboard-data", Fw32_set_clipboard_data,
 
   ok = EmptyClipboard () && SetClipboardData (CF_TEXT, htext);
 
+  CloseClipboard ();
+
+  /* Common sense says to read the sequence number inside the
+     OpenClipboard/ CloseClipboard block to avoid race conditions
+     where another app puts something on the clipboard straight after
+     us. But experience suggests that the sequence number from the
+     SetClipboardData is not allocated until we close the clipboard!
+     Since clipboard operations are normally user-driven, the race
+     condition is probably not going to really happen.  */
   if (clipboard_sequence_fn)
     last_clipboard_sequence_number = clipboard_sequence_fn ();
 
-  CloseClipboard ();
-
   if (ok) goto done;
 
  error: