From c052b7f8ef886aa0540545541fc78b2b20200132 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 18 Oct 2018 13:07:57 +0100 Subject: [PATCH] Fix segfault when deleting sheet pins. --- eeschema/operations_on_items_lists.cpp | 2 ++ eeschema/sch_screen.cpp | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/eeschema/operations_on_items_lists.cpp b/eeschema/operations_on_items_lists.cpp index f117679425..a9a2251925 100644 --- a/eeschema/operations_on_items_lists.cpp +++ b/eeschema/operations_on_items_lists.cpp @@ -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), diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index f3a7201573..f57d3d151f 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -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; } }