Set the proper symbol parent when duplicating
We need to handle both the case where the new symbol is an alias as well as free the proper memory after loading symbols in the duplicate Fixes https://gitlab.com/kicad/code/kicad/issues/12578
This commit is contained in:
parent
6df774a62f
commit
a0aff2dc70
|
@ -802,9 +802,6 @@ void SYMBOL_EDIT_FRAME::DuplicateSymbol( bool aFromClipboard )
|
||||||
if( !m_libMgr->LibraryExists( lib ) )
|
if( !m_libMgr->LibraryExists( lib ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
LIB_SYMBOL* srcSymbol = nullptr;
|
|
||||||
LIB_SYMBOL* newSymbol = nullptr;
|
|
||||||
|
|
||||||
std::vector<LIB_SYMBOL*> newSymbols;
|
std::vector<LIB_SYMBOL*> newSymbols;
|
||||||
|
|
||||||
if( aFromClipboard )
|
if( aFromClipboard )
|
||||||
|
@ -826,6 +823,7 @@ void SYMBOL_EDIT_FRAME::DuplicateSymbol( bool aFromClipboard )
|
||||||
wxString symbolSource = data.GetText();
|
wxString symbolSource = data.GetText();
|
||||||
|
|
||||||
std::unique_ptr<STRING_LINE_READER> reader = std::make_unique<STRING_LINE_READER>( TO_UTF8( symbolSource ), "Clipboard" );
|
std::unique_ptr<STRING_LINE_READER> reader = std::make_unique<STRING_LINE_READER>( TO_UTF8( symbolSource ), "Clipboard" );
|
||||||
|
LIB_SYMBOL* newSymbol = nullptr;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -848,7 +846,7 @@ void SYMBOL_EDIT_FRAME::DuplicateSymbol( bool aFromClipboard )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
srcSymbol = m_libMgr->GetBufferedSymbol( libId.GetLibItemName(), lib );
|
LIB_SYMBOL* srcSymbol = m_libMgr->GetBufferedSymbol( libId.GetLibItemName(), lib );
|
||||||
|
|
||||||
wxCHECK( srcSymbol, /* void */ );
|
wxCHECK( srcSymbol, /* void */ );
|
||||||
|
|
||||||
|
@ -861,7 +859,7 @@ void SYMBOL_EDIT_FRAME::DuplicateSymbol( bool aFromClipboard )
|
||||||
|
|
||||||
wxCHECK( srcParent, /* void */ );
|
wxCHECK( srcParent, /* void */ );
|
||||||
|
|
||||||
newSymbol->SetParent( srcParent.get() );
|
newSymbols.back()->SetParent( srcParent.get() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -879,7 +877,8 @@ void SYMBOL_EDIT_FRAME::DuplicateSymbol( bool aFromClipboard )
|
||||||
SyncLibraries( false );
|
SyncLibraries( false );
|
||||||
m_treePane->GetLibTree()->SelectLibId( LIB_ID( lib, newSymbols[0]->GetName() ) );
|
m_treePane->GetLibTree()->SelectLibId( LIB_ID( lib, newSymbols[0]->GetName() ) );
|
||||||
|
|
||||||
delete newSymbol;
|
for( LIB_SYMBOL* symbol : newSymbols )
|
||||||
|
delete symbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue