Commit e05e99d7 authored by Sebastian Lackner's avatar Sebastian Lackner Committed by Alexandre Julliard

server: Fix opening clipboard from multiple threads.

parent 9244cac3
...@@ -24,9 +24,18 @@ ...@@ -24,9 +24,18 @@
#include "wingdi.h" #include "wingdi.h"
#include "winuser.h" #include "winuser.h"
static DWORD WINAPI open_clipboard_thread(LPVOID arg)
{
HWND hWnd = arg;
ok(OpenClipboard(hWnd), "OpenClipboard failed\n");
return 0;
}
static void test_ClipboardOwner(void) static void test_ClipboardOwner(void)
{ {
HANDLE thread;
HWND hWnd1, hWnd2; HWND hWnd1, hWnd2;
DWORD dwret;
BOOL ret; BOOL ret;
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
...@@ -56,7 +65,13 @@ static void test_ClipboardOwner(void) ...@@ -56,7 +65,13 @@ static void test_ClipboardOwner(void)
ok( ret, "CloseClipboard error %d\n", GetLastError()); ok( ret, "CloseClipboard error %d\n", GetLastError());
ok(OpenClipboard(hWnd1), "OpenClipboard failed\n"); ok(OpenClipboard(hWnd1), "OpenClipboard failed\n");
ok(OpenClipboard(hWnd1), "OpenClipboard second time in the same hwnd 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);
ok(!CloseClipboard(), "CloseClipboard should fail if clipboard wasn't open\n");
ok(OpenClipboard(hWnd1), "OpenClipboard failed\n");
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = OpenClipboard(hWnd2); ret = OpenClipboard(hWnd2);
......
...@@ -138,7 +138,7 @@ void cleanup_clipboard_thread(struct thread *thread) ...@@ -138,7 +138,7 @@ void cleanup_clipboard_thread(struct thread *thread)
static int open_clipboard( struct clipboard *clipboard, user_handle_t win ) static int open_clipboard( struct clipboard *clipboard, user_handle_t win )
{ {
win = get_user_full_handle( win ); win = get_user_full_handle( win );
if (clipboard->open_thread && (clipboard->open_thread != current || clipboard->open_win != win)) if (clipboard->open_thread && clipboard->open_win != win)
{ {
set_error(STATUS_WAS_LOCKED); set_error(STATUS_WAS_LOCKED);
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment