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 8a52941624
commit 384f65c45e
1 changed files with 5 additions and 4 deletions

View File

@ -782,7 +782,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 );
} ) );
@ -796,6 +796,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;
@ -807,10 +809,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();