user32/tests: Properly maintain clipboard viewers chain.

Without this CloseClipboard() will crash on Windows 8 if executed after
test_messages().
This commit is contained in:
Nikolay Sivov 2014-03-07 14:30:56 +04:00 committed by Alexandre Julliard
parent c91c8ca92d
commit 83367e874c
1 changed files with 9 additions and 1 deletions

View File

@ -270,6 +270,7 @@ static void test_synthesized(void)
} }
static CRITICAL_SECTION clipboard_cs; static CRITICAL_SECTION clipboard_cs;
static HWND next_wnd;
static LRESULT CALLBACK clipboard_wnd_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) static LRESULT CALLBACK clipboard_wnd_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
{ {
switch(msg) { switch(msg) {
@ -277,7 +278,14 @@ static LRESULT CALLBACK clipboard_wnd_proc(HWND hwnd, UINT msg, WPARAM wp, LPARA
EnterCriticalSection(&clipboard_cs); EnterCriticalSection(&clipboard_cs);
LeaveCriticalSection(&clipboard_cs); LeaveCriticalSection(&clipboard_cs);
break; break;
case WM_CHANGECBCHAIN:
if (next_wnd == (HWND)wp)
next_wnd = (HWND)lp;
else if (next_wnd)
SendMessageA(next_wnd, msg, wp, lp);
break;
case WM_USER: case WM_USER:
ChangeClipboardChain(hwnd, next_wnd);
PostQuitMessage(0); PostQuitMessage(0);
break; break;
} }
@ -292,7 +300,7 @@ static DWORD WINAPI clipboard_thread(void *param)
EnterCriticalSection(&clipboard_cs); EnterCriticalSection(&clipboard_cs);
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
SetClipboardViewer(win); next_wnd = SetClipboardViewer(win);
ok(GetLastError() == 0xdeadbeef, "GetLastError = %d\n", GetLastError()); ok(GetLastError() == 0xdeadbeef, "GetLastError = %d\n", GetLastError());
LeaveCriticalSection(&clipboard_cs); LeaveCriticalSection(&clipboard_cs);