Fix segfault when deleting sheet pins.

This commit is contained in:
Jeff Young 2018-10-18 13:07:57 +01:00
parent eea949ce0a
commit c052b7f8ef
2 changed files with 6 additions and 3 deletions

View File

@ -189,6 +189,8 @@ void SCH_EDIT_FRAME::DeleteItem( SCH_ITEM* aItem, bool aAppend )
if( aItem->Type() == SCH_SHEET_PIN_T )
{
RemoveFromScreen( aItem );
// This item is attached to a node, and is not accessible by the global list directly.
SCH_SHEET* sheet = (SCH_SHEET*) aItem->GetParent();
wxCHECK_RET( (sheet != NULL) && (sheet->Type() == SCH_SHEET_T),

View File

@ -185,19 +185,20 @@ void SCH_SCREEN::DeleteItem( SCH_ITEM* aItem )
SetModify();
m_drawList.Remove( aItem );
if( aItem->Type() == SCH_SHEET_PIN_T )
{
// This structure is attached to a sheet, get the parent sheet object.
SCH_SHEET_PIN* sheetPin = (SCH_SHEET_PIN*) aItem;
SCH_SHEET* sheet = sheetPin->GetParent();
wxCHECK_RET( sheet,
wxT( "Sheet label parent not properly set, bad programmer!" ) );
wxCHECK_RET( sheet, wxT( "Sheet label parent not properly set, bad programmer!" ) );
sheet->RemovePin( sheetPin );
return;
}
else
{
delete m_drawList.Remove( aItem );
delete aItem;
}
}