empty clipboard, debug crash & failed to copy

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2022-02-22 23:53:28 +08:00
parent 2f6b457b3f
commit 555ff0085a
4 changed files with 72 additions and 16 deletions

View File

@@ -496,10 +496,10 @@ pub struct _cliprdr_client_context {
extern "C" {
pub(crate) fn init_cliprdr(context: *mut CliprdrClientContext) -> BOOL;
pub(crate) fn uninit_cliprdr(context: *mut CliprdrClientContext) -> BOOL;
pub fn empty_clipboard(
pub(crate) fn empty_cliprdr(
context: *mut CliprdrClientContext,
server_conn_id: u32,
remote_conn_id: u32,
server_conn_id: UINT32,
remote_conn_id: UINT32,
) -> BOOL;
}

View File

@@ -98,6 +98,20 @@ pub fn set_conn_enabled(server_conn_id: i32, remote_conn_id: i32, enabled: bool)
}
}
pub fn empty_clipboard(
context: &mut Box<CliprdrClientContext>,
server_conn_id: i32,
remote_conn_id: i32,
) -> bool {
unsafe {
TRUE == cliprdr::empty_cliprdr(
&mut (**context),
server_conn_id as u32,
remote_conn_id as u32,
)
}
}
pub fn server_clip_file(
context: &mut Box<CliprdrClientContext>,
conn_id: ConnID,
@@ -454,14 +468,16 @@ extern "C" fn check_enabled(server_conn_id: UINT32, remote_conn_id: UINT32) -> B
server_conn_enabled = true;
}
let mut remote_conn_enabled = false;
if remote_conn_id != 0 {
if let Some(true) = lock.remote_conn_enabled.get(&(remote_conn_id as i32)) {
remote_conn_enabled = true;
}
} else {
remote_conn_enabled = true;
}
// let mut remote_conn_enabled = false;
// remote connection is always enabled
// if remote_conn_id != 0 {
// if let Some(true) = lock.remote_conn_enabled.get(&(remote_conn_id as i32)) {
// remote_conn_enabled = true;
// }
// } else {
// remote_conn_enabled = true;
// }
let remote_conn_enabled = true;
if server_conn_enabled && remote_conn_enabled {
return TRUE;

View File

@@ -2792,6 +2792,23 @@ BOOL wf_cliprdr_uninit(wfClipboard *clipboard, CliprdrClientContext *cliprdr)
cliprdr->custom = NULL;
/* discard all contexts in clipboard */
if (try_open_clipboard(clipboard->hwnd))
{
if (!EmptyClipboard())
{
DEBUG_CLIPRDR("EmptyClipboard failed with 0x%x", GetLastError());
}
if (!CloseClipboard())
{
// critical error!!!
}
}
else
{
DEBUG_CLIPRDR("OpenClipboard failed with 0x%x", GetLastError());
}
if (clipboard->hwnd)
PostMessage(clipboard->hwnd, WM_QUIT, 0, 0);
@@ -2810,6 +2827,9 @@ BOOL wf_cliprdr_uninit(wfClipboard *clipboard, CliprdrClientContext *cliprdr)
if (clipboard->response_data_event)
CloseHandle(clipboard->response_data_event);
if (clipboard->data_obj_mutex)
CloseHandle(clipboard->data_obj_mutex);
if (clipboard->req_fevent)
CloseHandle(clipboard->req_fevent);
@@ -2851,7 +2871,7 @@ BOOL empty_cliprdr(CliprdrClientContext *context, UINT32 server_conn_id, UINT32
return FALSE;
}
while (0)
do
{
if (clipboard->data_obj != NULL)
{
@@ -2888,7 +2908,7 @@ BOOL empty_cliprdr(CliprdrClientContext *context, UINT32 server_conn_id, UINT32
// critical error!!!
}
rc = TRUE;
}
} while (0);
if (!ReleaseMutex(clipboard->data_obj_mutex))
{