pl_editor: fix a crash when trying to delete an item during its creation.

Fixes #12717
https://gitlab.com/kicad/code/kicad/issues/12717
This commit is contained in:
jean-pierre charras 2022-10-22 18:30:30 +02:00
parent 8e331628b6
commit df223cced4
1 changed files with 9 additions and 1 deletions

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-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2019-2022 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
@ -357,6 +357,14 @@ int PL_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent )
if( selection.Size() == 0 )
return 0;
// Do not delete an item if it is currently a new item being created to avoid a crash
// In this case the selection contains only one item.
DS_DRAW_ITEM_BASE* currItem = static_cast<DS_DRAW_ITEM_BASE*>( selection.Front() );
if( currItem->GetFlags() & ( IS_NEW ) )
return 0;
m_frame->SaveCopyInUndoList();
while( selection.Front() )