Add some defensive code to prevent crash when no undo record is stacked.

Fixes: lp:1838843
* https://bugs.launchpad.net/kicad/+bug/1838843
This commit is contained in:
Jeff Young 2019-08-03 17:14:56 -06:00
parent 5503727d3d
commit b6b26b4e1e
1 changed files with 8 additions and 5 deletions

View File

@ -362,14 +362,17 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
void SCH_EDIT_FRAME::RollbackSchematicFromUndo()
{
PICKED_ITEMS_LIST* undo = GetScreen()->PopCommandFromUndoList();
PutDataInPreviousState( undo, false );
undo->ClearListAndDeleteItems();
delete undo;
if( undo )
{
PutDataInPreviousState( undo, false );
undo->ClearListAndDeleteItems();
delete undo;
SetSheetNumberAndCount();
SetSheetNumberAndCount();
TestDanglingEnds();
TestDanglingEnds();
}
SyncView();
GetCanvas()->Refresh();