eeschema: Fix find from RTree change

The RTree doesn't keep pins and fields in the tree, so we need to search
for them differently.

Fixes #3979 | https://gitlab.com/kicad/code/kicad/issues/3979
This commit is contained in:
Seth Hillbrand 2020-03-03 09:34:04 -08:00
parent abb8088695
commit 20fde2c16f
1 changed files with 36 additions and 5 deletions

View File

@ -182,17 +182,48 @@ int SCH_EDITOR_CONTROL::UpdateFind( const TOOL_EVENT& aEvent )
SCH_ITEM* SCH_EDITOR_CONTROL::nextMatch(
SCH_SCREEN* aScreen, SCH_ITEM* aAfter, wxFindReplaceData* aData )
{
bool past_item = ( aAfter == nullptr );
bool past_item = true;
if( aAfter != nullptr )
{
past_item = false;
if( aAfter->Type() == SCH_PIN_T || aAfter->Type() == SCH_FIELD_T )
aAfter = static_cast<SCH_ITEM*>( aAfter->GetParent() );
}
for( auto item : aScreen->Items() )
{
if( item == aAfter )
{
past_item = true;
}
else if( past_item )
{
if( aData == &g_markersOnly && item->Type() == SCH_MARKER_T )
return item;
if( past_item
&& ( ( aData == &g_markersOnly && item->Type() == SCH_MARKER_T )
|| item->Matches( *aData, nullptr ) ) )
return item;
if( item->Matches( *aData, nullptr ) )
return item;
if( item->Type() == SCH_COMPONENT_T )
{
auto cmp = static_cast<SCH_COMPONENT*>( item );
for( auto field : cmp->GetFields() )
{
if( field->Matches( *aData, nullptr ) )
return field;
}
for( auto pin : cmp->GetSchPins() )
{
if( pin->Matches( *aData, nullptr ) )
return pin;
}
}
}
}
return nullptr;