Skip to content

Commit bf9b74d

Browse files
committed
8262446: DragAndDrop hangs on Windows
Reviewed-by: aivanov, serb, kizune
1 parent b1cc864 commit bf9b74d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/java.desktop/windows/native/libawt/windows/awt_DnDDT.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -141,6 +141,7 @@ static void ScaleDown(POINT &cp, HWND m_window) {
141141

142142
HRESULT __stdcall AwtDropTarget::DragEnter(IDataObject __RPC_FAR *pDataObj, DWORD grfKeyState, POINTL pt, DWORD __RPC_FAR *pdwEffect) {
143143
TRY;
144+
AwtToolkit::GetInstance().isInDoDragDropLoop = TRUE;
144145
if (NULL != m_pIDropTargetHelper) {
145146
m_pIDropTargetHelper->DragEnter(
146147
m_window,
@@ -160,6 +161,7 @@ HRESULT __stdcall AwtDropTarget::DragEnter(IDataObject __RPC_FAR *pDataObj, DWOR
160161
(IsLocalDnD() && !IsLocalDataObject(pDataObj)))
161162
{
162163
*pdwEffect = retEffect;
164+
AwtToolkit::GetInstance().isInDoDragDropLoop = FALSE;
163165
return ret;
164166
}
165167

@@ -171,6 +173,7 @@ HRESULT __stdcall AwtDropTarget::DragEnter(IDataObject __RPC_FAR *pDataObj, DWOR
171173
}
172174

173175
if (JNU_IsNull(env, m_dtcp) || !JNU_IsNull(env, safe_ExceptionOccurred(env))) {
176+
AwtToolkit::GetInstance().isInDoDragDropLoop = FALSE;
174177
return ret;
175178
}
176179

@@ -197,10 +200,12 @@ HRESULT __stdcall AwtDropTarget::DragEnter(IDataObject __RPC_FAR *pDataObj, DWOR
197200
env->ExceptionDescribe();
198201
env->ExceptionClear();
199202
actions = java_awt_dnd_DnDConstants_ACTION_NONE;
203+
AwtToolkit::GetInstance().isInDoDragDropLoop = FALSE;
200204
}
201205
} catch (std::bad_alloc&) {
202206
retEffect = ::convertActionsToDROPEFFECT(actions);
203207
*pdwEffect = retEffect;
208+
AwtToolkit::GetInstance().isInDoDragDropLoop = FALSE;
204209
throw;
205210
}
206211

@@ -416,6 +421,7 @@ void AwtDropTarget::DropDone(jboolean success, jint action) {
416421
m_dropSuccess = success;
417422
m_dropActions = action;
418423
AwtToolkit::GetInstance().QuitMessageLoop(AwtToolkit::EXIT_ENCLOSING_LOOP);
424+
AwtToolkit::GetInstance().isInDoDragDropLoop = FALSE;
419425
}
420426

421427
/**
@@ -1130,6 +1136,7 @@ void AwtDropTarget::UnloadCache() {
11301136

11311137
void AwtDropTarget::DragCleanup(void) {
11321138
UnloadCache();
1139+
AwtToolkit::GetInstance().isInDoDragDropLoop = FALSE;
11331140
}
11341141

11351142
BOOL AwtDropTarget::IsLocalDataObject(IDataObject __RPC_FAR *pDataObject) {

0 commit comments

Comments
 (0)