diff options
author | Jon TURNEY <jon.turney@dronecode.org.uk> | 2012-02-24 15:32:26 +0000 |
---|---|---|
committer | Jon TURNEY <jon.turney@dronecode.org.uk> | 2012-11-27 16:26:33 +0000 |
commit | 3ab95a2a5c848e8ce4c39be243fd5e2ac6bb1c1a (patch) | |
tree | 05e8e48a2f7fbd3fe7a57083d004081aceba7cba | |
parent | a4f357c620ae9e2270316197a61fb8e1d5183a51 (diff) |
hw/xwin: Ensure we own the clipboard before checking the format of it's contents
Ensure we own the clipboard before checking the format of it's contents, this
prevents the contents from changing underneath us.
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
-rw-r--r-- | hw/xwin/winclipboardxevents.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/hw/xwin/winclipboardxevents.c b/hw/xwin/winclipboardxevents.c index ce533c59f..5cae98caa 100644 --- a/hw/xwin/winclipboardxevents.c +++ b/hw/xwin/winclipboardxevents.c @@ -165,6 +165,24 @@ winClipboardFlushXEvents(HWND hwnd, break; } + /* Close clipboard if we have it open already */ + if (GetOpenClipboardWindow() == hwnd) { + CloseClipboard(); + } + + /* Access the clipboard */ + if (!OpenClipboard(hwnd)) { + ErrorF("winClipboardFlushXEvents - SelectionRequest - " + "OpenClipboard () failed: %08lx\n", GetLastError()); + + /* Abort */ + fAbort = TRUE; + goto winClipboardFlushXEvents_SelectionRequest_Done; + } + + /* Indicate that clipboard was opened */ + fCloseClipboard = TRUE; + /* Check that clipboard format is available */ if (fUseUnicode && !IsClipboardFormatAvailable(CF_UNICODETEXT)) { static int count; /* Hack to stop acroread spamming the log */ @@ -192,24 +210,6 @@ winClipboardFlushXEvents(HWND hwnd, goto winClipboardFlushXEvents_SelectionRequest_Done; } - /* Close clipboard if we have it open already */ - if (GetOpenClipboardWindow() == hwnd) { - CloseClipboard(); - } - - /* Access the clipboard */ - if (!OpenClipboard(hwnd)) { - ErrorF("winClipboardFlushXEvents - SelectionRequest - " - "OpenClipboard () failed: %08lx\n", GetLastError()); - - /* Abort */ - fAbort = TRUE; - goto winClipboardFlushXEvents_SelectionRequest_Done; - } - - /* Indicate that clipboard was opened */ - fCloseClipboard = TRUE; - /* Setup the string style */ if (event.xselectionrequest.target == XA_STRING) xiccesStyle = XStringStyle; |