Handle exceptions in user drop targets code in wxMSW
All exceptions thrown by wxDropTarget::OnXXX() must be caught and handled in the same way as we already do it for the exceptions in the event handlers as we can't let the exceptions escape into system/kernel code: while it can work in some cases, it doesn't work in general, e.g. exceptions simply disappear when they happen in 32 bit programs under 64 bit Windows 7.
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/msw/wrapwin.h"
|
||||
#include "wx/except.h"
|
||||
#include "wx/log.h"
|
||||
#endif
|
||||
|
||||
@@ -181,6 +182,8 @@ STDMETHODIMP wxIDropTarget::DragEnter(IDataObject *pIDataSource,
|
||||
POINTL pt,
|
||||
DWORD *pdwEffect)
|
||||
{
|
||||
wxTRY
|
||||
{
|
||||
wxLogTrace(wxTRACE_OleCalls, wxT("IDropTarget::DragEnter"));
|
||||
|
||||
wxASSERT_MSG( m_pIDataObject == NULL,
|
||||
@@ -243,6 +246,8 @@ STDMETHODIMP wxIDropTarget::DragEnter(IDataObject *pIDataSource,
|
||||
m_pTarget->MSWUpdateDragImageOnDragOver(pt.x, pt.y, res);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
wxCATCH_ALL( wxEvtHandler::WXConsumeException(); return E_UNEXPECTED; )
|
||||
}
|
||||
|
||||
|
||||
@@ -260,6 +265,8 @@ STDMETHODIMP wxIDropTarget::DragOver(DWORD grfKeyState,
|
||||
POINTL pt,
|
||||
LPDWORD pdwEffect)
|
||||
{
|
||||
wxTRY
|
||||
{
|
||||
// there are too many of them... wxLogDebug("IDropTarget::DragOver");
|
||||
|
||||
wxDragResult result;
|
||||
@@ -292,6 +299,8 @@ STDMETHODIMP wxIDropTarget::DragOver(DWORD grfKeyState,
|
||||
ConvertDragEffectToResult(*pdwEffect));
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
wxCATCH_ALL( wxEvtHandler::WXConsumeException(); return E_UNEXPECTED; )
|
||||
}
|
||||
|
||||
// Name : wxIDropTarget::DragLeave
|
||||
@@ -300,6 +309,8 @@ STDMETHODIMP wxIDropTarget::DragOver(DWORD grfKeyState,
|
||||
// Notes : good place to do any clean-up
|
||||
STDMETHODIMP wxIDropTarget::DragLeave()
|
||||
{
|
||||
wxTRY
|
||||
{
|
||||
wxLogTrace(wxTRACE_OleCalls, wxT("IDropTarget::DragLeave"));
|
||||
|
||||
// remove the UI feedback
|
||||
@@ -312,6 +323,8 @@ STDMETHODIMP wxIDropTarget::DragLeave()
|
||||
m_pTarget->MSWUpdateDragImageOnLeave();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
wxCATCH_ALL( wxEvtHandler::WXConsumeException(); return E_UNEXPECTED; )
|
||||
}
|
||||
|
||||
// Name : wxIDropTarget::Drop
|
||||
@@ -328,6 +341,8 @@ STDMETHODIMP wxIDropTarget::Drop(IDataObject *pIDataSource,
|
||||
POINTL pt,
|
||||
DWORD *pdwEffect)
|
||||
{
|
||||
wxTRY
|
||||
{
|
||||
wxLogTrace(wxTRACE_OleCalls, wxT("IDropTarget::Drop"));
|
||||
|
||||
// TODO I don't know why there is this parameter, but so far I assume
|
||||
@@ -370,6 +385,8 @@ STDMETHODIMP wxIDropTarget::Drop(IDataObject *pIDataSource,
|
||||
ConvertDragEffectToResult(*pdwEffect));
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
wxCATCH_ALL( wxEvtHandler::WXConsumeException(); return E_UNEXPECTED; )
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
Reference in New Issue
Block a user