Alexandre Julliard : server: Don' t release the clipboard owner window when the owner thread terminates.

Alexandre Julliard julliard at winehq.org
Thu Sep 1 09:55:30 CDT 2016


Module: wine
Branch: master
Commit: 2b8021d4d00e2e3c8cc4fd0c36ed0798bb19c111
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=2b8021d4d00e2e3c8cc4fd0c36ed0798bb19c111

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Sep  1 22:13:53 2016 +0900

server: Don't release the clipboard owner window when the owner thread terminates.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/user32/tests/clipboard.c | 18 ++++++++++++++++++
 server/clipboard.c            |  2 +-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/dlls/user32/tests/clipboard.c b/dlls/user32/tests/clipboard.c
index 7e0e41c..360ec8d 100644
--- a/dlls/user32/tests/clipboard.c
+++ b/dlls/user32/tests/clipboard.c
@@ -57,6 +57,14 @@ static DWORD WINAPI open_and_empty_clipboard_thread(LPVOID arg)
     return 0;
 }
 
+static DWORD WINAPI open_and_empty_clipboard_win_thread(LPVOID arg)
+{
+    HWND hwnd = CreateWindowA( "static", NULL, WS_POPUP, 0, 0, 10, 10, 0, 0, 0, NULL );
+    ok(OpenClipboard(hwnd), "%u: OpenClipboard failed\n", thread_from_line);
+    ok(EmptyClipboard(), "%u: EmptyClipboard failed\n", thread_from_line );
+    return 0;
+}
+
 static DWORD WINAPI set_clipboard_data_thread(LPVOID arg)
 {
     HWND hwnd = arg;
@@ -329,6 +337,8 @@ static void test_ClipboardOwner(void)
     ok( ret, "CloseClipboard error %d\n", GetLastError());
 
     run_thread( open_and_empty_clipboard_thread, 0, __LINE__ );
+    ok( !GetOpenClipboardWindow(), "wrong open window %p\n", GetOpenClipboardWindow() );
+    ok( !GetClipboardOwner(), "wrong owner window %p\n", GetClipboardOwner() );
 
     ret = OpenClipboard( 0 );
     ok( ret, "OpenClipboard error %d\n", GetLastError());
@@ -347,6 +357,14 @@ static void test_ClipboardOwner(void)
     ok( GetLastError() == ERROR_CLIPBOARD_NOT_OPEN, "wrong error %u\n", GetLastError() );
     ok( !IsClipboardFormatAvailable( CF_WAVE ), "SetClipboardData succeeded\n" );
 
+    run_thread( open_and_empty_clipboard_thread, GetDesktopWindow(), __LINE__ );
+    ok( !GetOpenClipboardWindow(), "wrong open window %p\n", GetOpenClipboardWindow() );
+    ok( GetClipboardOwner() == GetDesktopWindow(), "wrong owner window %p / %p\n",
+        GetClipboardOwner(), GetDesktopWindow() );
+
+    run_thread( open_and_empty_clipboard_win_thread, 0, __LINE__ );
+    ok( !GetOpenClipboardWindow(), "wrong open window %p\n", GetOpenClipboardWindow() );
+    ok( !GetClipboardOwner(), "wrong owner window %p\n", GetClipboardOwner() );
 }
 
 static void test_RegisterClipboardFormatA(void)
diff --git a/server/clipboard.c b/server/clipboard.c
index 21e6c9e..323fdb9 100644
--- a/server/clipboard.c
+++ b/server/clipboard.c
@@ -220,7 +220,7 @@ void cleanup_clipboard_thread(struct thread *thread)
 
     if ((clipboard = winstation->clipboard))
     {
-        if (thread == clipboard->owner_thread) release_clipboard( clipboard );
+        if (thread == clipboard->owner_thread) clipboard->owner_thread = NULL;
         if (thread == clipboard->open_thread)
         {
             user_handle_t viewer = close_clipboard( clipboard );




More information about the wine-cvs mailing list