From cf4c6fca847874356c712d7bc3c6b67bd1bbfbd4 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 11 Nov 2020 16:42:57 +0100 Subject: [PATCH] Fix spurious assert when dropping items is impossible in wxMSW Use correct drop effect in DropCleanup helper added in f5548e399e (Fix problem with dragged icon remaining on screen under MSW 10, 2020-01-11): using the value of the input pdwEffect argument was wrong, as it could be a combination of multiple DROPEFFECT_XXX flags, when we really need a single one here. This fixes a regression and the code should do exactly the same thing now when OnDrop() does not throw as it had done before that commit. See #18499. Closes #18965. --- src/msw/ole/droptgt.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/msw/ole/droptgt.cpp b/src/msw/ole/droptgt.cpp index 013a4cc4dc..155aa7e9c0 100644 --- a/src/msw/ole/droptgt.cpp +++ b/src/msw/ole/droptgt.cpp @@ -376,15 +376,18 @@ STDMETHODIMP wxIDropTarget::Drop(IDataObject *pIDataSource, public: DropCleanup(wxCOMPtr& pIDataObject, wxDropTarget* pTarget, - POINTL pt, - DWORD* pdwEffect) + POINTL pt) : m_pIDataObject(pIDataObject), m_pTarget(pTarget), - m_pdwEffect(pdwEffect), + m_dwEffect(DROPEFFECT_NONE), m_pt(pt) { } + // This can be optionally called to use an effect different from + // DROPEFFECT_NONE in the dtor. + void UpdateEffect(DWORD dwEffect) { m_dwEffect = dwEffect; } + ~DropCleanup() { // release the held object @@ -394,15 +397,15 @@ STDMETHODIMP wxIDropTarget::Drop(IDataObject *pIDataSource, m_pTarget->MSWUpdateDragImageOnData ( m_pt.x, m_pt.y, - ConvertDragEffectToResult(*m_pdwEffect) + ConvertDragEffectToResult(m_dwEffect) ); } private: wxCOMPtr& m_pIDataObject; wxDropTarget* m_pTarget; - DWORD* m_pdwEffect; + DWORD m_dwEffect; POINTL m_pt; - } dropCleanup(m_pIDataObject, m_pTarget, pt, pdwEffect); + } dropCleanup(m_pIDataObject, m_pTarget, pt); // first ask the drop target if it wants data if ( m_pTarget->OnDrop(pt.x, pt.y) ) { @@ -416,6 +419,8 @@ STDMETHODIMP wxIDropTarget::Drop(IDataObject *pIDataSource, if ( wxIsDragResultOk(rc) ) { // operation succeeded *pdwEffect = ConvertDragResultToEffect(rc); + + dropCleanup.UpdateEffect(*pdwEffect); } }