From b6b26b4e1ebaec13ae7baa83d459f17b2bbd8415 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 3 Aug 2019 17:14:56 -0600 Subject: [PATCH] Add some defensive code to prevent crash when no undo record is stacked. Fixes: lp:1838843 * https://bugs.launchpad.net/kicad/+bug/1838843 --- eeschema/schematic_undo_redo.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/eeschema/schematic_undo_redo.cpp b/eeschema/schematic_undo_redo.cpp index d91ebfae29..34078534bd 100644 --- a/eeschema/schematic_undo_redo.cpp +++ b/eeschema/schematic_undo_redo.cpp @@ -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();