summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnon Gilboa <agilboa@redhat.com>2012-03-01 13:06:24 +0200
committerArnon Gilboa <agilboa@redhat.com>2012-03-01 13:33:48 +0200
commit9eb73318cef817ecdba8bbf5f43f2cca84f48c4e (patch)
tree6e4a4cf8cdd8edcc31a8cd9dd89eb0f8872e4d13
parentd82ac68c5ac4dcfb831fe3bd9eefcd65e05f6ce0 (diff)
downloadspice-9eb73318cef817ecdba8bbf5f43f2cca84f48c4e.tar.gz
spice-9eb73318cef817ecdba8bbf5f43f2cca84f48c4e.tar.xz
spice-9eb73318cef817ecdba8bbf5f43f2cca84f48c4e.zip
client/windows: fix SetClipboardViewer error handling rhbz#786554
MSDN says the following about SetClipboardViewer(): "If an error occurs or there are no other windows in the clipboard viewer chain, the return value is NULL". Seems like the buggy case was "no other windows in the clipboard viewer chain", which explains the 3rd party clipboard manager workaround detailed in the bug description. It also seems like SetClipboardViewer() does not clear the error state on succcess. Calling SetLastError(0) before SetClipboardViewer() seems to solves this issue. Since we could not reproduce the bug on our env, the customer has verified on several of their systems that a private build resolved the issue.
-rw-r--r--client/windows/platform.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/client/windows/platform.cpp b/client/windows/platform.cpp
index 2b719f21..d3417e39 100644
--- a/client/windows/platform.cpp
+++ b/client/windows/platform.cpp
@@ -249,6 +249,7 @@ static void create_message_wind()
{
WNDCLASSEX wclass;
ATOM class_atom;
+ DWORD err;
const LPCWSTR class_name = L"spicec_platform_wclass";
@@ -272,9 +273,9 @@ static void create_message_wind()
if (!(platform_win = CreateWindow(class_name, L"", 0, 0, 0, 0, 0, NULL, NULL, instance, NULL))) {
THROW("create message window failed");
}
-
- if (!(next_clipboard_viewer_win = SetClipboardViewer(platform_win)) && GetLastError()) {
- THROW("set clipboard viewer failed");
+ SetLastError(0);
+ if (!(next_clipboard_viewer_win = SetClipboardViewer(platform_win)) && (err = GetLastError())) {
+ THROW("set clipboard viewer failed %u", err);
}
if (!(clipboard_event = CreateEvent(NULL, FALSE, FALSE, NULL))) {
THROW("create clipboard event failed");