Push reference and value special cases down into LIB_FIELD::compare().
Use COMPARE_FLAGS::EQUALITY and COMPARE_FLAGS::ERC when doing library diffs. Also fixes a few more cases where we weren't checking for -1 when doing a fieldID < MANDATORY_FIELDS. Fixes https://gitlab.com/kicad/code/kicad/-/issues/14830
This commit is contained in:
parent
dfebe516c5
commit
a4f16423c8
|
@ -247,16 +247,27 @@ int LIB_FIELD::compare( const LIB_ITEM& aOther, int aCompareFlags ) const
|
||||||
return retv;
|
return retv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else // assume we're sorting
|
||||||
{
|
{
|
||||||
if( m_id != tmp->m_id )
|
if( m_id != tmp->m_id )
|
||||||
return m_id - tmp->m_id;
|
return m_id - tmp->m_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
retv = GetText().CmpNoCase( tmp->GetText() );
|
bool ignoreFieldText = false;
|
||||||
|
|
||||||
if( retv != 0 )
|
if( m_id == REFERENCE_FIELD && ( aCompareFlags & COMPARE_FLAGS::EQUALITY ) )
|
||||||
return retv;
|
ignoreFieldText = true;
|
||||||
|
|
||||||
|
if( m_id == VALUE_FIELD && ( aCompareFlags & COMPARE_FLAGS::ERC ) )
|
||||||
|
ignoreFieldText = true;
|
||||||
|
|
||||||
|
if( !ignoreFieldText )
|
||||||
|
{
|
||||||
|
retv = GetText().CmpNoCase( tmp->GetText() );
|
||||||
|
|
||||||
|
if( retv != 0 )
|
||||||
|
return retv;
|
||||||
|
}
|
||||||
|
|
||||||
if( aCompareFlags & LIB_ITEM::COMPARE_FLAGS::EQUALITY )
|
if( aCompareFlags & LIB_ITEM::COMPARE_FLAGS::EQUALITY )
|
||||||
{
|
{
|
||||||
|
|
|
@ -377,7 +377,7 @@ int LIB_SYMBOL::Compare( const LIB_SYMBOL& aRhs, int aCompareFlags, REPORTER* aR
|
||||||
const LIB_FIELD* bField = nullptr;
|
const LIB_FIELD* bField = nullptr;
|
||||||
int tmp = 0;
|
int tmp = 0;
|
||||||
|
|
||||||
if( aField->GetId() < MANDATORY_FIELDS )
|
if( aField->GetId() >= 0 && aField->GetId() < MANDATORY_FIELDS )
|
||||||
bField = aRhs.GetFieldById( aField->GetId() );
|
bField = aRhs.GetFieldById( aField->GetId() );
|
||||||
else
|
else
|
||||||
bField = aRhs.FindField( aField->GetName() );
|
bField = aRhs.FindField( aField->GetName() );
|
||||||
|
@ -386,16 +386,6 @@ int LIB_SYMBOL::Compare( const LIB_SYMBOL& aRhs, int aCompareFlags, REPORTER* aR
|
||||||
{
|
{
|
||||||
tmp = 1;
|
tmp = 1;
|
||||||
}
|
}
|
||||||
else if( aField->GetId() == REFERENCE_FIELD )
|
|
||||||
{
|
|
||||||
if( aCompareFlags & LIB_ITEM::COMPARE_FLAGS::EQUALITY )
|
|
||||||
tmp = aFieldItem->compare( *bField, aCompareFlags );
|
|
||||||
}
|
|
||||||
else if( aField->GetId() == VALUE_FIELD )
|
|
||||||
{
|
|
||||||
if( ( aCompareFlags & LIB_ITEM::COMPARE_FLAGS::ERC ) == 0 )
|
|
||||||
tmp = aFieldItem->compare( *bField, aCompareFlags );
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tmp = aFieldItem->compare( *bField, aCompareFlags );
|
tmp = aFieldItem->compare( *bField, aCompareFlags );
|
||||||
|
|
|
@ -331,7 +331,9 @@ int EE_INSPECTION_TOOL::DiffSymbol( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
flattenedSchSymbol->SetFields( fields );
|
flattenedSchSymbol->SetFields( fields );
|
||||||
|
|
||||||
if( flattenedSchSymbol->Compare( *flattenedLibSymbol, 0, r ) == 0 )
|
int flags = LIB_ITEM::COMPARE_FLAGS::EQUALITY | LIB_ITEM::COMPARE_FLAGS::ERC;
|
||||||
|
|
||||||
|
if( flattenedSchSymbol->Compare( *flattenedLibSymbol, flags, r ) == 0 )
|
||||||
r->Report( _( "No relevant differences detected." ) );
|
r->Report( _( "No relevant differences detected." ) );
|
||||||
|
|
||||||
wxPanel* panel = dialog->AddBlankPage( _( "Visual" ) );
|
wxPanel* panel = dialog->AddBlankPage( _( "Visual" ) );
|
||||||
|
|
|
@ -1519,7 +1519,7 @@ void SCH_EDIT_TOOL::editFieldText( SCH_FIELD* aField )
|
||||||
wxString caption;
|
wxString caption;
|
||||||
|
|
||||||
// Use title caps for mandatory fields. "Edit Sheet name Field" looks dorky.
|
// Use title caps for mandatory fields. "Edit Sheet name Field" looks dorky.
|
||||||
if( parentType == SCH_SYMBOL_T && aField->GetId() < MANDATORY_FIELDS )
|
if( parentType == SCH_SYMBOL_T && aField->GetId() >= 0 && aField->GetId() < MANDATORY_FIELDS )
|
||||||
{
|
{
|
||||||
wxString translated_fieldname;
|
wxString translated_fieldname;
|
||||||
translated_fieldname = TEMPLATE_FIELDNAME::GetDefaultFieldName( aField->GetId(),
|
translated_fieldname = TEMPLATE_FIELDNAME::GetDefaultFieldName( aField->GetId(),
|
||||||
|
|
|
@ -524,7 +524,7 @@ void SYMBOL_EDITOR_EDIT_TOOL::editFieldProperties( LIB_FIELD* aField )
|
||||||
LIB_SYMBOL* parent = aField->GetParent();
|
LIB_SYMBOL* parent = aField->GetParent();
|
||||||
wxCHECK( parent, /* void */ );
|
wxCHECK( parent, /* void */ );
|
||||||
|
|
||||||
if( aField->GetId() < MANDATORY_FIELDS )
|
if( aField->GetId() >= 0 && aField->GetId() < MANDATORY_FIELDS )
|
||||||
caption.Printf( _( "Edit %s Field" ), TitleCaps( aField->GetName() ) );
|
caption.Printf( _( "Edit %s Field" ), TitleCaps( aField->GetName() ) );
|
||||||
else
|
else
|
||||||
caption.Printf( _( "Edit '%s' Field" ), aField->GetName() );
|
caption.Printf( _( "Edit '%s' Field" ), aField->GetName() );
|
||||||
|
|
Loading…
Reference in New Issue