diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp index dfc141a8c8..7f59e947e6 100644 --- a/eeschema/lib_field.cpp +++ b/eeschema/lib_field.cpp @@ -247,16 +247,27 @@ int LIB_FIELD::compare( const LIB_ITEM& aOther, int aCompareFlags ) const return retv; } } - else + else // assume we're sorting { if( m_id != tmp->m_id ) return m_id - tmp->m_id; } - retv = GetText().CmpNoCase( tmp->GetText() ); + bool ignoreFieldText = false; - if( retv != 0 ) - return retv; + if( m_id == REFERENCE_FIELD && ( aCompareFlags & COMPARE_FLAGS::EQUALITY ) ) + 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 ) { diff --git a/eeschema/lib_symbol.cpp b/eeschema/lib_symbol.cpp index 959c73d40d..ed9bc498c0 100644 --- a/eeschema/lib_symbol.cpp +++ b/eeschema/lib_symbol.cpp @@ -377,7 +377,7 @@ int LIB_SYMBOL::Compare( const LIB_SYMBOL& aRhs, int aCompareFlags, REPORTER* aR const LIB_FIELD* bField = nullptr; int tmp = 0; - if( aField->GetId() < MANDATORY_FIELDS ) + if( aField->GetId() >= 0 && aField->GetId() < MANDATORY_FIELDS ) bField = aRhs.GetFieldById( aField->GetId() ); else bField = aRhs.FindField( aField->GetName() ); @@ -386,16 +386,6 @@ int LIB_SYMBOL::Compare( const LIB_SYMBOL& aRhs, int aCompareFlags, REPORTER* aR { 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 { tmp = aFieldItem->compare( *bField, aCompareFlags ); diff --git a/eeschema/tools/ee_inspection_tool.cpp b/eeschema/tools/ee_inspection_tool.cpp index 00aa90e1ad..ae25d09954 100644 --- a/eeschema/tools/ee_inspection_tool.cpp +++ b/eeschema/tools/ee_inspection_tool.cpp @@ -331,7 +331,9 @@ int EE_INSPECTION_TOOL::DiffSymbol( const TOOL_EVENT& aEvent ) 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." ) ); wxPanel* panel = dialog->AddBlankPage( _( "Visual" ) ); diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index 9f9f1cc294..9b914c20a9 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -1519,7 +1519,7 @@ void SCH_EDIT_TOOL::editFieldText( SCH_FIELD* aField ) wxString caption; // 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; translated_fieldname = TEMPLATE_FIELDNAME::GetDefaultFieldName( aField->GetId(), diff --git a/eeschema/tools/symbol_editor_edit_tool.cpp b/eeschema/tools/symbol_editor_edit_tool.cpp index f15f039d89..7874474f6d 100644 --- a/eeschema/tools/symbol_editor_edit_tool.cpp +++ b/eeschema/tools/symbol_editor_edit_tool.cpp @@ -524,7 +524,7 @@ void SYMBOL_EDITOR_EDIT_TOOL::editFieldProperties( LIB_FIELD* aField ) LIB_SYMBOL* parent = aField->GetParent(); wxCHECK( parent, /* void */ ); - if( aField->GetId() < MANDATORY_FIELDS ) + if( aField->GetId() >= 0 && aField->GetId() < MANDATORY_FIELDS ) caption.Printf( _( "Edit %s Field" ), TitleCaps( aField->GetName() ) ); else caption.Printf( _( "Edit '%s' Field" ), aField->GetName() );