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.
This commit is contained in:
Vadim Zeitlin
2020-11-11 16:42:57 +01:00
parent a8b7802d38
commit cf4c6fca84

View File

@@ -376,15 +376,18 @@ STDMETHODIMP wxIDropTarget::Drop(IDataObject *pIDataSource,
public: public:
DropCleanup(wxCOMPtr<IDataObject>& pIDataObject, DropCleanup(wxCOMPtr<IDataObject>& pIDataObject,
wxDropTarget* pTarget, wxDropTarget* pTarget,
POINTL pt, POINTL pt)
DWORD* pdwEffect)
: m_pIDataObject(pIDataObject), : m_pIDataObject(pIDataObject),
m_pTarget(pTarget), m_pTarget(pTarget),
m_pdwEffect(pdwEffect), m_dwEffect(DROPEFFECT_NONE),
m_pt(pt) 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() ~DropCleanup()
{ {
// release the held object // release the held object
@@ -394,15 +397,15 @@ STDMETHODIMP wxIDropTarget::Drop(IDataObject *pIDataSource,
m_pTarget->MSWUpdateDragImageOnData m_pTarget->MSWUpdateDragImageOnData
( (
m_pt.x, m_pt.y, m_pt.x, m_pt.y,
ConvertDragEffectToResult(*m_pdwEffect) ConvertDragEffectToResult(m_dwEffect)
); );
} }
private: private:
wxCOMPtr<IDataObject>& m_pIDataObject; wxCOMPtr<IDataObject>& m_pIDataObject;
wxDropTarget* m_pTarget; wxDropTarget* m_pTarget;
DWORD* m_pdwEffect; DWORD m_dwEffect;
POINTL m_pt; 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 // first ask the drop target if it wants data
if ( m_pTarget->OnDrop(pt.x, pt.y) ) { if ( m_pTarget->OnDrop(pt.x, pt.y) ) {
@@ -416,6 +419,8 @@ STDMETHODIMP wxIDropTarget::Drop(IDataObject *pIDataSource,
if ( wxIsDragResultOk(rc) ) { if ( wxIsDragResultOk(rc) ) {
// operation succeeded // operation succeeded
*pdwEffect = ConvertDragResultToEffect(rc); *pdwEffect = ConvertDragResultToEffect(rc);
dropCleanup.UpdateEffect(*pdwEffect);
} }
} }