From a4201ea8336638dfed8e04433de676cde72ff7ac Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Tue, 17 Nov 2020 14:28:10 -0800 Subject: [PATCH] Fix crash in libedit LIB_ITEM is not derived from SCH_ITEM but they share a selection model --- eeschema/tools/ee_selection_tool.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index 612b89ca61..a7b243482c 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -1578,7 +1578,9 @@ void EE_SELECTION_TOOL::highlight( EDA_ITEM* aItem, int aMode, EE_SELECTION* aGr // Highlight pins and fields. (All the other component children are currently only // represented in the LIB_PART and will inherit the settings of the parent component.) - static_cast( aItem )->RunOnChildren( + if( SCH_ITEM* sch_item = dynamic_cast( aItem ) ) + { + sch_item->RunOnChildren( [&]( SCH_ITEM* aChild ) { if( aMode == SELECTED ) @@ -1586,6 +1588,7 @@ void EE_SELECTION_TOOL::highlight( EDA_ITEM* aItem, int aMode, EE_SELECTION* aGr else if( aMode == BRIGHTENED ) aChild->SetSelected(); } ); + } if( itemType == SCH_PIN_T || itemType == SCH_FIELD_T || itemType == SCH_SHEET_PIN_T ) getView()->Update( aItem->GetParent() ); @@ -1608,7 +1611,9 @@ void EE_SELECTION_TOOL::unhighlight( EDA_ITEM* aItem, int aMode, EE_SELECTION* a // Unhighlight pins and fields. (All the other component children are currently only // represented in the LIB_PART.) - static_cast( aItem )->RunOnChildren( + if( SCH_ITEM* sch_item = dynamic_cast( aItem ) ) + { + sch_item->RunOnChildren( [&]( SCH_ITEM* aChild ) { if( aMode == SELECTED ) @@ -1616,6 +1621,7 @@ void EE_SELECTION_TOOL::unhighlight( EDA_ITEM* aItem, int aMode, EE_SELECTION* a else if( aMode == BRIGHTENED ) aChild->ClearBrightened(); } ); + } if( itemType == SCH_PIN_T || itemType == SCH_FIELD_T || itemType == SCH_SHEET_PIN_T ) getView()->Update( aItem->GetParent() );