From 3048caa25dbb4f82f74236a3be50c63f7f749bee Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 4 Mar 2014 14:07:16 +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/branches/WX_3_0_BRANCH@76076 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + src/msw/ole/droptgt.cpp | 37 ++++++++++++++++++++----------------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 173869152d..db7ab86e8a 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -617,6 +617,7 @@ wxMSW: - Disable the use of compiler TLS to avoid mysterious crashes in plugins. - Added solution files for MSVS 2012 and 2013 (Artur Wieczorek). +- Fix handling of unsupported formats in dnd (jwiesemann). - Fix blank wxBitmapComboBox dropdown appearance. - Fix clicking on checkboxes in wxDataViewCtrl. - Many improvements to alpha transparency handling (Artur Wieczorek). 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);