Attempt to fix crash with RMB on un-selected graphic line.

Fixes https://gitlab.com/kicad/code/kicad/issues/4414
This commit is contained in:
Jeff Young 2020-05-12 19:48:36 +01:00
parent f679be4101
commit ec5f7b35a9
1 changed files with 11 additions and 8 deletions

View File

@ -199,9 +199,9 @@ bool SCH_EDIT_TOOL::Init()
&& aSel.AreAllItemsIdentical() ) )
return false;
EDA_ITEM* item = static_cast<EDA_ITEM*>( aSel.Front() );
EDA_ITEM* firstItem = static_cast<EDA_ITEM*>( aSel.Front() );
switch( item->Type() )
switch( firstItem->Type() )
{
case SCH_COMPONENT_T:
case SCH_SHEET_T:
@ -215,12 +215,15 @@ bool SCH_EDIT_TOOL::Init()
return aSel.GetSize() == 1;
case SCH_LINE_T:
return std::all_of( aSel.GetItems().begin(), aSel.GetItems().end(),
[&]( EDA_ITEM* selItem )
{
SCH_LINE* line = dynamic_cast<SCH_LINE*>( selItem );
return line && line->IsGraphicLine();
} );
for( EDA_ITEM* item : aSel.GetItems() )
{
SCH_LINE* line = dynamic_cast<SCH_LINE*>( item );
if( !line || !line->IsGraphicLine() )
return false;
}
return true;
default:
return false;