Browse Source

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
7.0
Jon Evans 3 years ago
parent
commit
d0024bd9f7
  1. 8
      common/widgets/unit_binder.cpp

8
common/widgets/unit_binder.cpp

@ -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 );
} );
}
}
Loading…
Cancel
Save