Remove confused dynamic_cast

dynamic_cast could not resolve the cast chain leading to a null undo
point.  Since we know the item to be LIB_ITEM, we can use static_cast
anyway and avoid the overhead.

Fixes #3771 | https://gitlab.com/kicad/code/kicad/issues/3771
This commit is contained in:
Seth Hillbrand 2020-01-16 06:09:40 -08:00
parent 801093c3b5
commit f1fcf3f1dc
2 changed files with 10 additions and 5 deletions

View File

@ -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();

View File

@ -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<LIB_EDIT_FRAME*>( m_frame );
wxASSERT( editFrame );
editFrame->SaveCopyInUndoList( dynamic_cast<LIB_ITEM*>( aItem ), aType, aAppend );
editFrame->SaveCopyInUndoList( static_cast<LIB_ITEM*>( 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<SCH_ITEM*>( aItem->GetParent() ), UR_CHANGED, aAppend );
static_cast<SCH_ITEM*>( aItem->GetParent() ), UR_CHANGED, aAppend );
else
editFrame->SaveCopyInUndoList( dynamic_cast<SCH_ITEM*>( aItem ), aType, aAppend );
editFrame->SaveCopyInUndoList( static_cast<SCH_ITEM*>( aItem ), aType, aAppend );
}
if( selected && aItem->HasFlag( TEMP_SELECTED ) )