diff --git a/pcbnew/pcb_io/odbpp/odb_component.cpp b/pcbnew/pcb_io/odbpp/odb_component.cpp index 50f15ff309..409b95623d 100644 --- a/pcbnew/pcb_io/odbpp/odb_component.cpp +++ b/pcbnew/pcb_io/odbpp/odb_component.cpp @@ -61,6 +61,21 @@ ODB_COMPONENT& COMPONENTS_MANAGER::AddComponent( const FOOTPRINT* aFp, comp.m_comp_name = wxString::Format( "UNNAMED%zu", m_compList.size() ); } + wxString base_comp_name = comp.m_comp_name; + + if( !m_usedCompNames.insert( comp.m_comp_name ).second ) + { + size_t suffix = 1; + wxString candidate; + + do + { + candidate = wxString::Format( "%s_%zu", base_comp_name, suffix++ ); + } while( !m_usedCompNames.insert( candidate ).second ); + + comp.m_comp_name = candidate; + } + for( PCB_FIELD* field : aFp->GetFields() ) { if( field->GetId() == REFERENCE_FIELD ) diff --git a/pcbnew/pcb_io/odbpp/odb_component.h b/pcbnew/pcb_io/odbpp/odb_component.h index 5dcdd48870..82590e8634 100644 --- a/pcbnew/pcb_io/odbpp/odb_component.h +++ b/pcbnew/pcb_io/odbpp/odb_component.h @@ -24,6 +24,7 @@ #include "odb_util.h" #include +#include #include #include "odb_attribute.h" #include "odb_eda_data.h" @@ -42,6 +43,7 @@ public: private: std::list m_compList; + std::set m_usedCompNames; }; diff --git a/pcbnew/pcb_io/odbpp/odb_entity.cpp b/pcbnew/pcb_io/odbpp/odb_entity.cpp index 2bd87ae592..f8d5694a34 100644 --- a/pcbnew/pcb_io/odbpp/odb_entity.cpp +++ b/pcbnew/pcb_io/odbpp/odb_entity.cpp @@ -728,6 +728,9 @@ void ODB_STEP_ENTITY::InitEdaData() const EDA_DATA::PACKAGE& eda_pkg = m_edaData.GetPackage( hash_fp_item( fp_pkg.get(), HASH_POS | REL_COORD ) ); + if( fp->Pads().empty() ) + continue; + ODB_COMPONENT& comp = iter->second->InitComponentData( fp, eda_pkg ); for( int i = 0; i < fp->Pads().size(); ++i )