Skip to content

Commit

Permalink
Fix crash when drag drop is cancelled/cleaned up before windows callback
Browse files Browse the repository at this point in the history
  • Loading branch information
solwllms committed Jan 13, 2025
1 parent d72701a commit 57f8c59
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion valve/qtbase/src/plugins/platforms/windows/qwindowsdrag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,15 @@ QWindowsOleDropSource::GiveFeedback(DWORD dwEffect)
const Qt::DropAction action = translateToQDragDropAction(dwEffect);
m_drag->updateAction(action);

const qint64 currentCacheKey = m_drag->currentDrag()->dragCursor(action).cacheKey();
// Sol: seeing it's possible currentDrag has been deleted by the time the win32 callback into here is called
const QDrag *drag = m_drag->currentDrag();
if (!drag) {
QWindowsDrag *windowsDrag = QWindowsDrag::instance();
windowsDrag->cancelDrag();
return ResultFromScode(DRAGDROP_S_USEDEFAULTCURSORS);
}

const qint64 currentCacheKey = drag->dragCursor(action).cacheKey();
auto it = m_cursors.constFind(action);
// If a custom drag cursor is set, check its cache key to detect changes.
if (it == m_cursors.constEnd() || (currentCacheKey && currentCacheKey != it.value().cacheKey)) {
Expand Down

0 comments on commit 57f8c59

Please sign in to comment.