From e2fe8927ccd7c479c1f0f8e9038d9998cfe7fc06 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 4 Mar 2014 14:07:48 +0000 Subject: [PATCH] Don't accept data in unsupported format in wxMSW dnd code. We wrongly pretended to accept the data in formats which we didn't actually accept and showed misleading cursors to the user. Fix this by partially reverting some of the changes of r72668 (see #14697). Closes #16042. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76078 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/ole/droptgt.cpp | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/msw/ole/droptgt.cpp b/src/msw/ole/droptgt.cpp index 182ae4e3d0..45b67c3c16 100644 --- a/src/msw/ole/droptgt.cpp +++ b/src/msw/ole/droptgt.cpp @@ -218,6 +218,16 @@ STDMETHODIMP wxIDropTarget::DragEnter(IDataObject *pIDataSource, } #endif // 0 + if ( !m_pTarget->MSWIsAcceptedData(pIDataSource) ) { + // we don't accept this kind of data + *pdwEffect = DROPEFFECT_NONE; + + // Don't do anything else if we don't support this format at all, notably + // don't call our OnEnter() below which would show misleading cursor to + // the user. + return S_OK; + } + // for use in OnEnter and OnDrag calls m_pTarget->MSWSetDataSource(pIDataSource); @@ -225,26 +235,19 @@ STDMETHODIMP wxIDropTarget::DragEnter(IDataObject *pIDataSource, m_pIDataObject = pIDataSource; m_pIDataObject->AddRef(); - if ( !m_pTarget->MSWIsAcceptedData(pIDataSource) ) { - // we don't accept this kind of data - *pdwEffect = DROPEFFECT_NONE; - } - else + // we need client coordinates to pass to wxWin functions + if ( !ScreenToClient(m_hwnd, (POINT *)&pt) ) { - // we need client coordinates to pass to wxWin functions - if ( !ScreenToClient(m_hwnd, (POINT *)&pt) ) - { - wxLogLastError(wxT("ScreenToClient")); - } - - // give some visual feedback - *pdwEffect = ConvertDragResultToEffect( - m_pTarget->OnEnter(pt.x, pt.y, ConvertDragEffectToResult( - GetDropEffect(grfKeyState, m_pTarget->GetDefaultAction(), *pdwEffect)) - ) - ); + wxLogLastError(wxT("ScreenToClient")); } + // give some visual feedback + *pdwEffect = ConvertDragResultToEffect( + m_pTarget->OnEnter(pt.x, pt.y, ConvertDragEffectToResult( + GetDropEffect(grfKeyState, m_pTarget->GetDefaultAction(), *pdwEffect)) + ) + ); + // update drag image const wxDragResult res = ConvertDragEffectToResult(*pdwEffect); m_pTarget->MSWUpdateDragImageOnEnter(pt.x, pt.y, res);