server: Fix opening clipboard from multiple threads.

This commit is contained in:
Sebastian Lackner 2015-06-03 18:12:07 +02:00 committed by Alexandre Julliard
parent 9244cac3af
commit e05e99d754
2 changed files with 17 additions and 2 deletions

View File

@ -24,9 +24,18 @@
#include "wingdi.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)
{
HANDLE thread;
HWND hWnd1, hWnd2;
DWORD dwret;
BOOL ret;
SetLastError(0xdeadbeef);
@ -56,7 +65,13 @@ static void test_ClipboardOwner(void)
ok( ret, "CloseClipboard error %d\n", GetLastError());
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);
ret = OpenClipboard(hWnd2);

View File

@ -138,7 +138,7 @@ 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 && clipboard->open_win != win)
{
set_error(STATUS_WAS_LOCKED);
return 0;