X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/786646f3c201dc18ef065219288207734c8855f9..9b69526274b023fa1460b29a92bea8bf82e4703f:/src/common/wincmn.cpp diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index 2b63369661..24158367eb 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -214,6 +214,8 @@ bool wxWindowBase::CreateBase(wxWindowBase *parent, // common clean up wxWindowBase::~wxWindowBase() { + wxASSERT_MSG( GetCapture() != this, wxT("attempt to destroy window with mouse capture") ); + // FIXME if these 2 cases result from programming errors in the user code // we should probably assert here instead of silently fixing them @@ -631,6 +633,41 @@ wxEvtHandler *wxWindowBase::PopEventHandler(bool deleteHandler) return handlerA; } +bool wxWindowBase::RemoveEventHandler(wxEvtHandler *handler) +{ + wxCHECK_MSG( handler, FALSE, _T("RemoveEventHandler(NULL) called") ); + + wxEvtHandler *handlerPrev = NULL, + *handlerCur = GetEventHandler(); + while ( handlerCur ) + { + wxEvtHandler *handlerNext = handlerCur->GetNextHandler(); + + if ( handlerCur == handler ) + { + if ( handlerPrev ) + { + handlerPrev->SetNextHandler(handlerNext); + } + else + { + SetEventHandler(handlerNext); + } + + handler->SetNextHandler(NULL); + + return TRUE; + } + + handlerPrev = handlerCur; + handlerCur = handlerNext; + } + + wxFAIL_MSG( _T("where has the event handler gone?") ); + + return FALSE; +} + // ---------------------------------------------------------------------------- // cursors, fonts &c // ---------------------------------------------------------------------------- @@ -1625,7 +1662,7 @@ struct WXDLLEXPORT wxWindowNext void wxWindowBase::CaptureMouse() { wxLogTrace(_T("mousecapture"), _T("CaptureMouse(0x%08x)"), this); - + wxWindow *winOld = GetCapture(); if ( winOld ) { @@ -1642,6 +1679,10 @@ void wxWindowBase::CaptureMouse() void wxWindowBase::ReleaseMouse() { + wxLogTrace(_T("mousecapture"), _T("ReleaseMouse(0x%08x)"), this); + + wxASSERT_MSG( GetCapture() == this, wxT("attempt to release mouse, but this window hasn't captured it") ) + DoReleaseMouse(); if ( ms_winCaptureNext )