eemodern: fixed use-after-free crash in LIB_EDIT_TOOL::DoDelete()

This commit is contained in:
Tomasz Włostowski 2019-05-22 21:35:03 +02:00
parent 37e057173c
commit 2b38b23a5e
1 changed files with 10 additions and 3 deletions

View File

@ -272,6 +272,8 @@ int LIB_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent )
saveCopyInUndoList( part, UR_LIBEDIT );
std::set<LIB_ITEM *> toDelete;
for( EDA_ITEM* item : items )
{
if( item->Type() == LIB_PIN_T )
@ -279,7 +281,7 @@ int LIB_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent )
LIB_PIN* pin = static_cast<LIB_PIN*>( item );
wxPoint pos = pin->GetPosition();
part->RemoveDrawItem( pin );
toDelete.insert( pin );
// when pin editing is synchronized, all pins of the same body style are removed:
if( m_frame->SynchronizePins() )
@ -298,16 +300,21 @@ int LIB_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent )
if( pin->GetConvert() != curr_convert )
continue;
part->RemoveDrawItem( pin );
toDelete.insert( pin );
}
}
}
else
{
part->RemoveDrawItem( (LIB_ITEM*) item );
toDelete.insert( (LIB_ITEM*) item );
}
}
for( auto item : toDelete )
{
part->RemoveDrawItem( item );
}
m_frame->RebuildView();
m_frame->OnModify();