Fixed an assert on pasting items in the Footprint Library Editor

The assert in the title line verifies that an item does not belong to
any DLIST when it is being added to one. Items in clipboard are already
owned by DLISTs, therefore they need to be removed from the original
DLISTs before being added to new ones.
This commit is contained in:
Maciej Suminski 2018-06-15 13:44:09 +02:00
parent 316ff2898d
commit 7d66dc0cc3
1 changed files with 11 additions and 5 deletions

View File

@ -873,17 +873,23 @@ int PCBNEW_CONTROL::PasteItemsFromClipboard( const TOOL_EVENT& aEvent )
if( editModules ) if( editModules )
{ {
auto mod = static_cast<MODULE*>( clipItem ); auto oldModule = static_cast<MODULE*>( clipItem );
auto newModule = board()->m_Modules.GetFirst();
for( auto pad : mod->Pads() ) for( D_PAD* pad = oldModule->PadsList(), *next = nullptr; pad; pad = next )
{ {
pad->SetParent( board()->m_Modules.GetFirst() ); next = pad->Next();
oldModule->Remove( pad );
pad->SetParent( newModule );
items.push_back( pad ); items.push_back( pad );
} }
for( auto item : mod->GraphicalItems() ) for( BOARD_ITEM* item = oldModule->GraphicalItemsList(), *next = nullptr;
item; item = next )
{ {
item->SetParent( board()->m_Modules.GetFirst() ); next = item->Next();
oldModule->Remove( item );
item->SetParent( newModule );
items.push_back( item ); items.push_back( item );
} }
} }