Bug 1465513: Call IDropTargetHelper::DragLeave before IDropTargetHelper::DragEnter. r=dmajor,NeilDeakin

This is an attempt clean up any stale information to try and solve crashes later
in the drag in nsNativeDragTarget::DragOver.

Differential Revision: https://phabricator.services.mozilla.com/D100124
This commit is contained in:
Bob Owen 2020-12-21 18:49:40 +00:00
parent 4ab52ee39d
commit 81777ea3b9

View File

@ -237,6 +237,12 @@ nsNativeDragTarget::DragEnter(LPDATAOBJECT pIDataSource, DWORD grfKeyState,
// Drag and drop image helper
if (GetDropTargetHelper()) {
// We get a lot of crashes (often uncaught by our handler) later on during
// DragOver calls, see bug 1465513. It looks like this might be because
// we're not cleaning up previous drags fully and now released resources get
// used. Calling IDropTargetHelper::DragLeave before DragEnter seems to fix
// this for at least one reproduction of this crash.
GetDropTargetHelper()->DragLeave();
POINT pt = {ptl.x, ptl.y};
GetDropTargetHelper()->DragEnter(mHWnd, pIDataSource, &pt, *pdwEffect);
}
@ -313,6 +319,8 @@ nsNativeDragTarget::DragOver(DWORD grfKeyState, POINTL ptl, LPDWORD pdwEffect) {
// Drag and drop image helper
if (GetDropTargetHelper()) {
if (dragImageChanged) {
// See comment in nsNativeDragTarget::DragEnter.
GetDropTargetHelper()->DragLeave();
// The drop helper only updates the image during DragEnter, so emulate
// a DragEnter if the image was changed.
POINT pt = {ptl.x, ptl.y};