2015-06-03 09:13:44 -07:00
|
|
|
From 2683d3a1e5f86624b1227933ad620dde8aefa171 Mon Sep 17 00:00:00 2001
|
2015-05-02 22:36:40 -07:00
|
|
|
From: Sebastian Lackner <sebastian@fds-team.de>
|
2015-06-03 09:13:44 -07:00
|
|
|
Date: Wed, 3 Jun 2015 18:12:07 +0200
|
|
|
|
Subject: server: Fix opening clipboard from multiple threads.
|
2015-05-02 22:36:40 -07:00
|
|
|
|
|
|
|
---
|
2015-06-03 09:13:44 -07:00
|
|
|
dlls/user32/tests/clipboard.c | 14 ++++++++++++++
|
2015-05-02 22:36:40 -07:00
|
|
|
server/clipboard.c | 3 ++-
|
2015-06-03 09:13:44 -07:00
|
|
|
2 files changed, 16 insertions(+), 1 deletion(-)
|
2015-05-02 22:36:40 -07:00
|
|
|
|
|
|
|
diff --git a/dlls/user32/tests/clipboard.c b/dlls/user32/tests/clipboard.c
|
2015-06-03 09:13:44 -07:00
|
|
|
index a9aef84..6f6cb39 100644
|
2015-05-02 22:36:40 -07:00
|
|
|
--- a/dlls/user32/tests/clipboard.c
|
|
|
|
+++ b/dlls/user32/tests/clipboard.c
|
2015-06-03 09:13:44 -07:00
|
|
|
@@ -24,9 +24,18 @@
|
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
2015-05-02 22:36:40 -07:00
|
|
|
|
|
|
|
+static DWORD WINAPI open_clipboard_thread(LPVOID arg)
|
|
|
|
+{
|
|
|
|
+ HWND hWnd = arg;
|
|
|
|
+ ok(OpenClipboard(hWnd), "OpenClipboard second time in the same hwnd failed\n");
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
static void test_ClipboardOwner(void)
|
|
|
|
{
|
|
|
|
+ HANDLE thread;
|
|
|
|
HWND hWnd1, hWnd2;
|
|
|
|
+ DWORD dwret;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2015-06-03 09:13:44 -07:00
|
|
|
@@ -56,6 +65,11 @@ static void test_ClipboardOwner(void)
|
2015-05-02 22:36:40 -07:00
|
|
|
ok( ret, "CloseClipboard error %d\n", GetLastError());
|
|
|
|
|
|
|
|
ok(OpenClipboard(hWnd1), "OpenClipboard failed\n");
|
|
|
|
+ thread = CreateThread(NULL, 0, open_clipboard_thread, hWnd1, 0, NULL);
|
|
|
|
+ ok(thread != NULL, "CreateThread failed with error %d\n", GetLastError());
|
|
|
|
+ dwret = WaitForSingleObject(thread, 1000);
|
|
|
|
+ ok(dwret == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %u\n", dwret);
|
|
|
|
+ CloseHandle(thread);
|
2015-06-03 09:13:44 -07:00
|
|
|
ok(OpenClipboard(hWnd1), "OpenClipboard second time in the same hwnd failed\n");
|
2015-05-02 22:36:40 -07:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
diff --git a/server/clipboard.c b/server/clipboard.c
|
2015-06-03 09:13:44 -07:00
|
|
|
index 9acee98..ad7ae6f 100644
|
2015-05-02 22:36:40 -07:00
|
|
|
--- a/server/clipboard.c
|
|
|
|
+++ b/server/clipboard.c
|
2015-06-03 09:13:44 -07:00
|
|
|
@@ -138,8 +138,9 @@ void cleanup_clipboard_thread(struct thread *thread)
|
|
|
|
static int open_clipboard( struct clipboard *clipboard, user_handle_t win )
|
|
|
|
{
|
|
|
|
win = get_user_full_handle( win );
|
|
|
|
- if (clipboard->open_thread && (clipboard->open_thread != current || clipboard->open_win != win))
|
|
|
|
+ if (clipboard->open_thread)
|
|
|
|
{
|
|
|
|
+ if (clipboard->open_win == win) return 1;
|
|
|
|
set_error(STATUS_WAS_LOCKED);
|
|
|
|
return 0;
|
|
|
|
}
|
2015-05-02 22:36:40 -07:00
|
|
|
--
|
2015-06-03 09:13:44 -07:00
|
|
|
2.4.2
|
2015-05-02 22:36:40 -07:00
|
|
|
|