diff --git a/eeschema/libedit/libedit_undo_redo.cpp b/eeschema/libedit/libedit_undo_redo.cpp index c038c1e867..752194300e 100644 --- a/eeschema/libedit/libedit_undo_redo.cpp +++ b/eeschema/libedit/libedit_undo_redo.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2007 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2014-2017 KiCad Developers, see CHANGELOG.TXT for contributors. + * Copyright (C) 2014-2020 KiCad Developers, see CHANGELOG.TXT for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -162,6 +162,11 @@ void LIB_EDIT_FRAME::RollbackPartFromUndo() // Load the last undo entry PICKED_ITEMS_LIST* undoCommand = GetScreen()->PopCommandFromUndoList(); + + // Check if we were already at the top of the stack + if( !undoCommand ) + return; + ITEM_PICKER undoWrapper = undoCommand->PopItem(); delete undoCommand; LIB_PART* part = (LIB_PART*) undoWrapper.GetItem(); diff --git a/eeschema/tools/ee_tool_base.h b/eeschema/tools/ee_tool_base.h index 47059fc48f..9595f6bfcb 100644 --- a/eeschema/tools/ee_tool_base.h +++ b/eeschema/tools/ee_tool_base.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2019 CERN - * Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2019-2020 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -129,7 +129,7 @@ protected: LIB_EDIT_FRAME* editFrame = dynamic_cast( m_frame ); wxASSERT( editFrame ); - editFrame->SaveCopyInUndoList( dynamic_cast( aItem ), aType, aAppend ); + editFrame->SaveCopyInUndoList( static_cast( aItem ), aType, aAppend ); } else { @@ -138,9 +138,9 @@ protected: if( itemType == SCH_PIN_T || itemType == SCH_FIELD_T || itemType == SCH_SHEET_PIN_T ) editFrame->SaveCopyInUndoList( - dynamic_cast( aItem->GetParent() ), UR_CHANGED, aAppend ); + static_cast( aItem->GetParent() ), UR_CHANGED, aAppend ); else - editFrame->SaveCopyInUndoList( dynamic_cast( aItem ), aType, aAppend ); + editFrame->SaveCopyInUndoList( static_cast( aItem ), aType, aAppend ); } if( selected && aItem->HasFlag( TEMP_SELECTED ) )