From ccf2a63f45f2a33bb69bf35da2f06a694f1b0115 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Thu, 3 Feb 2022 11:17:41 -0800 Subject: [PATCH] When undoing creation of the sheet, get out first We can't stay in a sheet that is deleted by the action of undo. Checks the current sheet and, if we are currently using it, ensures that the following action is to leave the current sheet Fixes https://gitlab.com/kicad/code/kicad/issues/10733 --- eeschema/schematic_undo_redo.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/eeschema/schematic_undo_redo.cpp b/eeschema/schematic_undo_redo.cpp index bcb7a6fe9e..1ef5fdf4a3 100644 --- a/eeschema/schematic_undo_redo.cpp +++ b/eeschema/schematic_undo_redo.cpp @@ -22,6 +22,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +#include #include #include #include @@ -283,7 +284,13 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList ) } if( status == UNDO_REDO::NEWITEM ) { - // new items are deleted on undo + // If we are removing the current sheet, get out first + if( SCH_SHEET* sheet = dyn_cast( eda_item ) ) + { + if( sheet->GetScreen() == GetScreen() ) + GetToolManager()->RunAction( EE_ACTIONS::leaveSheet ); + } + RemoveFromScreen( eda_item, screen ); aList->SetPickedItemStatus( UNDO_REDO::DELETED, ii ); }