From 83367e874cc65d22fa5f30b2e3512c011818125f Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Fri, 7 Mar 2014 14:30:56 +0400 Subject: [PATCH] user32/tests: Properly maintain clipboard viewers chain. Without this CloseClipboard() will crash on Windows 8 if executed after test_messages(). --- dlls/user32/tests/clipboard.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/dlls/user32/tests/clipboard.c b/dlls/user32/tests/clipboard.c index d9ebb23a1bb..40218be4c7a 100644 --- a/dlls/user32/tests/clipboard.c +++ b/dlls/user32/tests/clipboard.c @@ -270,6 +270,7 @@ static void test_synthesized(void) } static CRITICAL_SECTION clipboard_cs; +static HWND next_wnd; static LRESULT CALLBACK clipboard_wnd_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) { switch(msg) { @@ -277,7 +278,14 @@ static LRESULT CALLBACK clipboard_wnd_proc(HWND hwnd, UINT msg, WPARAM wp, LPARA EnterCriticalSection(&clipboard_cs); LeaveCriticalSection(&clipboard_cs); 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: + ChangeClipboardChain(hwnd, next_wnd); PostQuitMessage(0); break; } @@ -292,7 +300,7 @@ static DWORD WINAPI clipboard_thread(void *param) EnterCriticalSection(&clipboard_cs); SetLastError(0xdeadbeef); - SetClipboardViewer(win); + next_wnd = SetClipboardViewer(win); ok(GetLastError() == 0xdeadbeef, "GetLastError = %d\n", GetLastError()); LeaveCriticalSection(&clipboard_cs);