Make sure find/replace respects different values in the hierarchy.
Fixes https://gitlab.com/kicad/code/kicad/issues/8328
This commit is contained in:
parent
9b35757e18
commit
1ed54d2314
|
@ -587,6 +587,7 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
|
|||
SetSheetNumberAndCount();
|
||||
|
||||
RecomputeIntersheetRefs();
|
||||
GetCurrentSheet().UpdateAllScreenReferences();
|
||||
|
||||
// re-create junctions if needed. Eeschema optimizes wires by merging
|
||||
// colinear segments. If a schematic is saved without a valid
|
||||
|
|
|
@ -394,29 +394,53 @@ bool SCH_FIELD::IsReplaceable() const
|
|||
|
||||
bool SCH_FIELD::Replace( const wxFindReplaceData& aSearchData, void* aAuxData )
|
||||
{
|
||||
bool isReplaced = false;
|
||||
wxString text;
|
||||
bool resolve = false; // Replace in source text, not shown text
|
||||
bool isReplaced = false;
|
||||
|
||||
if( m_parent && m_parent->Type() == SCH_COMPONENT_T )
|
||||
{
|
||||
SCH_COMPONENT* parentSymbol = static_cast<SCH_COMPONENT*>( m_parent );
|
||||
|
||||
if( m_id == REFERENCE_FIELD )
|
||||
switch( m_id )
|
||||
{
|
||||
wxCHECK_MSG( aAuxData != NULL, false,
|
||||
wxT( "Cannot replace reference designator without valid sheet path." ) );
|
||||
case REFERENCE_FIELD:
|
||||
wxCHECK_MSG( aAuxData, false, wxT( "Need sheetpath to replace in refdes." ) );
|
||||
|
||||
if( !( aSearchData.GetFlags() & FR_REPLACE_REFERENCES ) )
|
||||
return false;
|
||||
|
||||
wxString text = parentSymbol->GetRef((SCH_SHEET_PATH*) aAuxData );
|
||||
|
||||
text = parentSymbol->GetRef( (SCH_SHEET_PATH*) aAuxData );
|
||||
isReplaced = EDA_ITEM::Replace( aSearchData, text );
|
||||
|
||||
if( isReplaced )
|
||||
parentSymbol->SetRef((SCH_SHEET_PATH*) aAuxData, text );
|
||||
}
|
||||
else
|
||||
{
|
||||
parentSymbol->SetRef( (SCH_SHEET_PATH*) aAuxData, text );
|
||||
|
||||
break;
|
||||
|
||||
case VALUE_FIELD:
|
||||
wxCHECK_MSG( aAuxData, false, wxT( "Need sheetpath to replace in value field." ) );
|
||||
|
||||
text = parentSymbol->GetValue((SCH_SHEET_PATH*) aAuxData, resolve );
|
||||
isReplaced = EDA_ITEM::Replace( aSearchData, text );
|
||||
|
||||
if( isReplaced )
|
||||
parentSymbol->SetValue( (SCH_SHEET_PATH*) aAuxData, text );
|
||||
|
||||
break;
|
||||
|
||||
case FOOTPRINT_FIELD:
|
||||
wxCHECK_MSG( aAuxData, false, wxT( "Need sheetpath to replace in footprint field." ) );
|
||||
|
||||
text = parentSymbol->GetFootprint((SCH_SHEET_PATH*) aAuxData, resolve );
|
||||
isReplaced = EDA_ITEM::Replace( aSearchData, text );
|
||||
|
||||
if( isReplaced )
|
||||
parentSymbol->SetFootprint( (SCH_SHEET_PATH*) aAuxData, text );
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
isReplaced = EDA_TEXT::Replace( aSearchData );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -477,6 +477,7 @@ int SCH_EDITOR_CONTROL::ReplaceAndFindNext( const TOOL_EVENT& aEvent )
|
|||
if( item->Replace( *data, sheet ) )
|
||||
{
|
||||
m_frame->UpdateItem( item );
|
||||
m_frame->GetCurrentSheet().UpdateAllScreenReferences();
|
||||
m_frame->OnModify();
|
||||
}
|
||||
|
||||
|
@ -490,6 +491,7 @@ int SCH_EDITOR_CONTROL::ReplaceAndFindNext( const TOOL_EVENT& aEvent )
|
|||
int SCH_EDITOR_CONTROL::ReplaceAll( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
wxFindReplaceData* data = m_frame->GetFindReplaceData();
|
||||
bool modified = false;
|
||||
|
||||
if( !data )
|
||||
return FindAndReplace( ACTIONS::find.MakeEvent() );
|
||||
|
@ -506,13 +508,19 @@ int SCH_EDITOR_CONTROL::ReplaceAll( const TOOL_EVENT& aEvent )
|
|||
if( item->Replace( *data, sheet ) )
|
||||
{
|
||||
m_frame->UpdateItem( item );
|
||||
m_frame->OnModify();
|
||||
modified = true;
|
||||
}
|
||||
|
||||
item = nextMatch( screen, sheet, dynamic_cast<SCH_ITEM*>( item ), data );
|
||||
}
|
||||
}
|
||||
|
||||
if( modified )
|
||||
{
|
||||
m_frame->GetCurrentSheet().UpdateAllScreenReferences();
|
||||
m_frame->OnModify();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue