server: Cleanup clipboard information upon window destruction.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2016-08-23 20:58:44 +09:00
parent 43e38153ee
commit 5962df3a1e
4 changed files with 25 additions and 4 deletions

View File

@ -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());

View File

@ -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)

View File

@ -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 */

View File

@ -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 );