Fix incorrect management of SCH_SHEET_PIN items when adding or removing them.
Especially new SCH_SHEET_PIN items were added twice, thus creating crashes. Fixes: lp:1799606 https://bugs.launchpad.net/kicad/+bug/1799606
This commit is contained in:
parent
7d02c11880
commit
dc21a60531
|
@ -189,9 +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.
|
||||
// This item is attached to its parent hierarchical sheet,
|
||||
// and is not accessible by the global list directly and cannot be removed from this list.
|
||||
SCH_SHEET* sheet = (SCH_SHEET*) aItem->GetParent();
|
||||
wxCHECK_RET( (sheet != NULL) && (sheet->Type() == SCH_SHEET_T),
|
||||
wxT( "Sheet label has invalid parent item." ) );
|
||||
|
|
|
@ -645,6 +645,7 @@ void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
|
|||
return;
|
||||
|
||||
viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER_MODAL, false );
|
||||
|
||||
if( viewlibFrame && !viewlibFrame->Close() ) // Can close modal component viewer?
|
||||
return;
|
||||
}
|
||||
|
@ -1398,13 +1399,16 @@ void SCH_EDIT_FRAME::addCurrentItemToScreen()
|
|||
SetSheetNumberAndCount();
|
||||
}
|
||||
|
||||
if( item->Type() != SCH_SHEET_PIN_T ) // for SCH_SHEET_PIN_T: will be added later
|
||||
// to the SCH_SHEET parent
|
||||
{
|
||||
if( !screen->CheckIfOnDrawList( item ) ) // don't want a loop!
|
||||
AddToScreen( item );
|
||||
}
|
||||
|
||||
if( undoItem == item )
|
||||
{
|
||||
SetRepeatItem( item );
|
||||
|
||||
SaveCopyInUndoList( undoItem, UR_NEW );
|
||||
}
|
||||
else
|
||||
|
@ -1414,7 +1418,7 @@ void SCH_EDIT_FRAME::addCurrentItemToScreen()
|
|||
// currently: sheet pin or component field.
|
||||
// currently, only a sheet pin can be found as new item,
|
||||
// because new component fields have a specific handling, and do not appears here
|
||||
SaveCopyInUndoList( undoItem, UR_CHANGED );
|
||||
SaveCopyInUndoList( undoItem, UR_CHANGED ); // Save the parent sheet
|
||||
|
||||
if( item->Type() == SCH_SHEET_PIN_T )
|
||||
( (SCH_SHEET*)undoItem )->AddPin( (SCH_SHEET_PIN*) item );
|
||||
|
|
|
@ -185,8 +185,6 @@ 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.
|
||||
|
@ -198,6 +196,7 @@ void SCH_SCREEN::DeleteItem( SCH_ITEM* aItem )
|
|||
}
|
||||
else
|
||||
{
|
||||
m_drawList.Remove( aItem );
|
||||
delete aItem;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue