Module: wine Branch: master Commit: 5962df3a1e2e19545e5ad8e6be4c5ed3b1cb2e29 URL: http://source.winehq.org/git/wine.git/?a=commit;h=5962df3a1e2e19545e5ad8e6be...
Author: Alexandre Julliard julliard@winehq.org Date: Tue Aug 23 20:58:44 2016 +0900
server: Cleanup clipboard information upon window destruction.
Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/user32/tests/clipboard.c | 8 ++++---- server/clipboard.c | 19 +++++++++++++++++++ server/user.h | 1 + server/window.c | 1 + 4 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/dlls/user32/tests/clipboard.c b/dlls/user32/tests/clipboard.c index 9893e8a..b6914da 100644 --- a/dlls/user32/tests/clipboard.c +++ b/dlls/user32/tests/clipboard.c @@ -266,13 +266,13 @@ static void test_ClipboardOwner(void) ok( ret, "DestroyWindow error %d\n", GetLastError()); SetLastError(0xdeadbeef); ok(!GetClipboardOwner() && GetLastError() == 0xdeadbeef, "clipboard should not be owned\n"); - todo_wine ok(!GetClipboardViewer() && GetLastError() == 0xdeadbeef, "viewer still exists\n"); - todo_wine ok(!GetOpenClipboardWindow() && GetLastError() == 0xdeadbeef, "clipboard should not be open\n"); + ok(!GetClipboardViewer() && GetLastError() == 0xdeadbeef, "viewer still exists\n"); + ok(!GetOpenClipboardWindow() && GetLastError() == 0xdeadbeef, "clipboard should not be open\n");
SetLastError( 0xdeadbeef ); ret = CloseClipboard(); - todo_wine ok( !ret, "CloseClipboard succeeded\n" ); - todo_wine ok( GetLastError() == ERROR_CLIPBOARD_NOT_OPEN, "wrong error %u\n", GetLastError() ); + ok( !ret, "CloseClipboard succeeded\n" ); + ok( GetLastError() == ERROR_CLIPBOARD_NOT_OPEN, "wrong error %u\n", GetLastError() );
ret = OpenClipboard( 0 ); ok( ret, "OpenClipboard error %d\n", GetLastError()); diff --git a/server/clipboard.c b/server/clipboard.c index ca0067a..98df230 100644 --- a/server/clipboard.c +++ b/server/clipboard.c @@ -111,6 +111,25 @@ static struct clipboard *get_process_clipboard(void) return clipboard; }
+/* cleanup clipboard information upon window destruction */ +void cleanup_clipboard_window( struct desktop *desktop, user_handle_t window ) +{ + struct clipboard *clipboard = desktop->winstation->clipboard; + + if (!clipboard) return; + + if (clipboard->open_win == window) + { + clipboard->open_win = 0; + clipboard->open_thread = NULL; + } + if (clipboard->owner_win == window) + { + clipboard->owner_win = 0; + clipboard->owner_thread = NULL; + } + if (clipboard->viewer == window) clipboard->viewer = 0; +}
/* Called when thread terminates to allow release of clipboard */ void cleanup_clipboard_thread(struct thread *thread) diff --git a/server/user.h b/server/user.h index 89646f1..2f70674 100644 --- a/server/user.h +++ b/server/user.h @@ -91,6 +91,7 @@ extern void free_process_user_handles( struct process *process );
/* clipboard functions */
+extern void cleanup_clipboard_window( struct desktop *desktop, user_handle_t window ); extern void cleanup_clipboard_thread( struct thread *thread );
/* hook functions */ diff --git a/server/window.c b/server/window.c index 143b60c..4f30079 100644 --- a/server/window.c +++ b/server/window.c @@ -1855,6 +1855,7 @@ void destroy_window( struct window *win ) if (win == progman_window) progman_window = NULL; if (win == taskman_window) taskman_window = NULL; free_hotkeys( win->desktop, win->handle ); + cleanup_clipboard_window( win->desktop, win->handle ); free_user_handle( win->handle ); destroy_properties( win ); list_remove( &win->entry );