Special case undo for items with instance data.

Fixes https://gitlab.com/kicad/code/kicad/issues/11102
This commit is contained in:
Jeff Young 2022-03-19 19:36:20 +00:00
parent 63b5ad7df1
commit cc165129fd
1 changed files with 25 additions and 0 deletions

View File

@ -324,6 +324,31 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList )
{
case UNDO_REDO::CHANGED:
item->SwapData( alt_item );
// Special cases for items which have instance data
if( item->GetParent() && item->GetParent()->Type() == SCH_SYMBOL_T
&& item->Type() == SCH_FIELD_T )
{
SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item->GetParent() );
if( field->GetId() == REFERENCE_FIELD )
{
symbol->SetRef( m_schematic->GetSheets().FindSheetForScreen( screen ),
field->GetText() );
}
else if( field->GetId() == VALUE_FIELD )
{
symbol->SetValue( m_schematic->GetSheets().FindSheetForScreen( screen ),
field->GetText() );
}
else if( field->GetId() == FOOTPRINT_FIELD )
{
symbol->SetFootprint( m_schematic->GetSheets().FindSheetForScreen( screen ),
field->GetText() );
}
}
break;
case UNDO_REDO::EXCHANGE_T: