Be careful of infobar outliving symbol.

Fixes https://gitlab.com/kicad/code/kicad/issues/14680
This commit is contained in:
Jeff Young 2023-05-04 11:29:13 +01:00
parent 9e735fc940
commit 7cc014cf9e
1 changed files with 5 additions and 4 deletions

View File

@ -781,7 +781,7 @@ void SYMBOL_EDIT_FRAME::SetCurSymbol( LIB_SYMBOL* aSymbol, bool aUpdateZoom )
wxEmptyString );
button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
[&]( wxHyperlinkEvent& aEvent )
[=]( wxHyperlinkEvent& aEvent )
{
InvokeSchEditSymbolLibTable( &Kiway(), this );
} ) );
@ -795,6 +795,8 @@ void SYMBOL_EDIT_FRAME::SetCurSymbol( LIB_SYMBOL* aSymbol, bool aUpdateZoom )
else if( IsSymbolAlias() )
{
wxString parentSymbolName = m_symbol->GetParent().lock()->GetName();
int unit = GetUnit();
int convert = GetConvert();
wxString msg;
wxString link;
@ -806,10 +808,9 @@ void SYMBOL_EDIT_FRAME::SetCurSymbol( LIB_SYMBOL* aSymbol, bool aUpdateZoom )
wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY, link, wxEmptyString );
button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
[&]( wxHyperlinkEvent& aEvent )
[=]( wxHyperlinkEvent& aEvent )
{
LoadSymbolFromCurrentLib( m_symbol->GetParent().lock()->GetName(),
GetUnit(), GetConvert() );
LoadSymbolFromCurrentLib( parentSymbolName, unit, convert );
} ) );
infobar->RemoveAllButtons();