Properties: clear text ctrl from unit binder before it is destroyed

The lifetime of this text ctrl is managed by the property grid, so
we need to catch when it is hidden before destruction in order to avoid stale pointers being used to handle unit change events.

Credit to @dsa-t for the fix
This commit is contained in:
Jon Evans 2022-12-05 19:33:20 -05:00
parent 77b763f8ba
commit d0024bd9f7
1 changed files with 8 additions and 0 deletions

View File

@ -642,5 +642,13 @@ void PROPERTY_EDITOR_UNIT_BINDER::SetControl( wxWindow* aControl )
nullptr, this );
m_valueCtrl->Connect( wxEVT_LEFT_UP, wxMouseEventHandler( PROPERTY_EDITOR_UNIT_BINDER::onClick ),
nullptr, this );
m_valueCtrl->Bind( wxEVT_SET_FOCUS, &PROPERTY_EDITOR_UNIT_BINDER::onSetFocus, this );
m_valueCtrl->Bind( wxEVT_SHOW,
[&]( wxShowEvent& e )
{
if( !e.IsShown() )
SetControl( nullptr );
} );
}
}