Suppress assertions caused by closing the window while mouse is captured

Closing the window while dragging with unsaved changes causes a dialog box, triggering a capture-lost event. Closing the window while dragging without unsaved changes causes an assertion about destroying a window with mouse capture.
This commit is contained in:
mitxela 2021-01-20 19:01:51 +00:00 committed by Wayne Stambaugh
parent 39be962a69
commit bfd7a9e956
2 changed files with 9 additions and 0 deletions

View File

@ -114,6 +114,8 @@ WX_VIEW_CONTROLS::WX_VIEW_CONTROLS( VIEW* aView, wxScrolledCanvas* aParentPanel
wxScrollWinEventHandler( WX_VIEW_CONTROLS::onScroll ), NULL, this );
m_parentPanel->Connect( wxEVT_SCROLLWIN_LINEDOWN,
wxScrollWinEventHandler( WX_VIEW_CONTROLS::onScroll ), NULL, this );
m_parentPanel->Connect( wxEVT_MOUSE_CAPTURE_LOST,
wxMouseEventHandler( WX_VIEW_CONTROLS::onCaptureLost ), NULL, this );
m_cursorWarped = false;
@ -128,6 +130,8 @@ WX_VIEW_CONTROLS::WX_VIEW_CONTROLS( VIEW* aView, wxScrolledCanvas* aParentPanel
WX_VIEW_CONTROLS::~WX_VIEW_CONTROLS()
{
if( m_parentPanel->HasCapture() )
m_parentPanel->ReleaseMouse();
}
@ -477,6 +481,10 @@ void WX_VIEW_CONTROLS::onLeave( wxMouseEvent& aEvent )
}
void WX_VIEW_CONTROLS::onCaptureLost( wxMouseEvent& aEvent )
{
// This method must be present to suppress the capture-lost assertion
}
void WX_VIEW_CONTROLS::onTimer( wxTimerEvent& aEvent )
{

View File

@ -64,6 +64,7 @@ public:
void onLeave( wxMouseEvent& WXUNUSED( aEvent ) );
void onTimer( wxTimerEvent& WXUNUSED( aEvent ) );
void onScroll( wxScrollWinEvent& aEvent );
void onCaptureLost( wxMouseEvent& WXUNUSED( aEvent ) );
/**
* Enable or disable mouse cursor grabbing (limits the movement field only to the panel area).