Add m_isClosing guard in an attempt to prevent KICAD-1XF.

This commit is contained in:
Jeff Young 2023-11-18 12:45:09 +00:00
parent 341124d831
commit 0de966f9ce
2 changed files with 15 additions and 8 deletions

View File

@ -81,6 +81,7 @@ DIALOG_SHIM::DIALOG_SHIM( wxWindow* aParent, wxWindowID id, const wxString& titl
m_useCalculatedSize( false ),
m_firstPaintEvent( true ),
m_initialFocusTarget( nullptr ),
m_isClosing( false ),
m_qmodal_loop( nullptr ),
m_qmodal_showing( false ),
m_qmodal_parent_disabler( nullptr ),
@ -140,6 +141,8 @@ DIALOG_SHIM::DIALOG_SHIM( wxWindow* aParent, wxWindowID id, const wxString& titl
DIALOG_SHIM::~DIALOG_SHIM()
{
m_isClosing = true;
Unbind( wxEVT_CLOSE_WINDOW, &DIALOG_SHIM::OnCloseWindow, this );
Unbind( wxEVT_BUTTON, &DIALOG_SHIM::OnButton, this );
Unbind( wxEVT_PAINT, &DIALOG_SHIM::OnPaint, this );
@ -151,14 +154,14 @@ DIALOG_SHIM::~DIALOG_SHIM()
if( wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( child ) )
{
textCtrl->Disconnect( wxEVT_SET_FOCUS,
wxFocusEventHandler( DIALOG_SHIM::onChildSetFocus ), nullptr,
this );
wxFocusEventHandler( DIALOG_SHIM::onChildSetFocus ),
nullptr, this );
}
else if( wxStyledTextCtrl* scintilla = dynamic_cast<wxStyledTextCtrl*>( child ) )
{
scintilla->Disconnect( wxEVT_SET_FOCUS,
wxFocusEventHandler( DIALOG_SHIM::onChildSetFocus ), nullptr,
this );
wxFocusEventHandler( DIALOG_SHIM::onChildSetFocus ),
nullptr, this );
}
else
{
@ -618,10 +621,13 @@ void DIALOG_SHIM::onChildSetFocus( wxFocusEvent& aEvent )
{
// When setting focus to a text control reset the before-edit value.
if( wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( aEvent.GetEventObject() ) )
m_beforeEditValues[ textCtrl ] = textCtrl->GetValue();
else if( wxStyledTextCtrl* scintilla = dynamic_cast<wxStyledTextCtrl*>( aEvent.GetEventObject() ) )
m_beforeEditValues[ scintilla ] = scintilla->GetText();
if( !m_isClosing )
{
if( wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( aEvent.GetEventObject() ) )
m_beforeEditValues[ textCtrl ] = textCtrl->GetValue();
else if( wxStyledTextCtrl* scintilla = dynamic_cast<wxStyledTextCtrl*>( aEvent.GetEventObject() ) )
m_beforeEditValues[ scintilla ] = scintilla->GetText();
}
aEvent.Skip();
}

View File

@ -213,6 +213,7 @@ protected:
// the initial-focus SetFocus() call to the first paint event.
bool m_firstPaintEvent;
wxWindow* m_initialFocusTarget;
bool m_isClosing;
WX_EVENT_LOOP* m_qmodal_loop; // points to nested event_loop, NULL means not qmodal
// and dismissed