[PATCH 0/1] MR11107: user32:Unify drop_target cleanup at end of drag_drop_drop to avoid spurious...
user32:Unify drop_target cleanup at end of drag_drop_drop to avoid spurious DragLeave in next DnD session Change-Id: I1213239a7c7981c4d3f7cb56281e3687527c7885 Bug: drag_drop_drop calls IDropTarget_Drop but fails to Release+NULL drop_target. When the next XdndEnter arrives, drag_drop_enter releases the old data_object, whose destructor sees the stale drop_target is non-NULL,incorrectly calls IDropTarget_DragLeave, and interrupts the new drag session. Fix: Remove Release+NULL from the else-if branch, add a single Release+NULL after if (drop_file) as the sole cleanup point, avoiding double-release. Cannot reproduce in Wine tests: DoDragDrop API bypasses clipboard.c entirely and has no stale pointer issue; the X11 DnD path requires cross-process COM deferred Release timing, which cannot be simulated in a simple Wine test case. MSDN:https://learn.microsoft.com/en-us/windows/win32/api/oleidl/nf-oleidl-idropta... [drop_receiver.exe](/uploads/85f0571bc354238576bf9e50a62f12e2/drop_receiver.exe) [drop_receiver.c](/uploads/b409b8a12a352dae9dbd4dab5fa322d2/drop_receiver.c) -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11107
From: zhangzhou <zhangzhou@uniontech.com> Change-Id: I1213239a7c7981c4d3f7cb56281e3687527c7885 --- dlls/user32/clipboard.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dlls/user32/clipboard.c b/dlls/user32/clipboard.c index 3c3ba7c584c..074e81c13b0 100644 --- a/dlls/user32/clipboard.c +++ b/dlls/user32/clipboard.c @@ -1276,8 +1276,6 @@ DWORD drag_drop_drop( HWND hwnd ) { HRESULT hr = IDropTarget_DragLeave( object->drop_target ); if (FAILED(hr)) WARN( "IDropTarget_DragLeave returned %#lx\n", hr ); - IDropTarget_Release( object->drop_target ); - object->drop_target = NULL; } if (drop_file) @@ -1306,6 +1304,12 @@ DWORD drag_drop_drop( HWND hwnd ) } } + if (object->drop_target) + { + IDropTarget_Release( object->drop_target ); + object->drop_target = NULL; + } + TRACE("effectRequested(0x%lx) accept(%d) performed(0x%lx) at x(%ld),y(%ld)\n", object->target_effect, accept, effect, object->target_pos.x, object->target_pos.y); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11107
participants (2)
-
zhangzhou -
zhou zhang (@zhouzhang)