changeset 54974:64d01f3f16e5

(Fw32_set_clipboard_data): Get sequence number after closing the clipboard.
author Jason Rumney <jasonr@gnu.org>
date Sun, 18 Apr 2004 18:34:03 +0000
parents 0c5529232126
children cb7efcd51e78
files src/w32select.c
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/w32select.c	Sun Apr 18 18:33:01 2004 +0000
+++ b/src/w32select.c	Sun Apr 18 18:34:03 2004 +0000
@@ -259,11 +259,18 @@
 
   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: