From b1bf5127fa21d5b5c794378531d8640658a46632 Mon Sep 17 00:00:00 2001
From: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
Date: Thu, 6 Mar 2025 23:23:09 +0100
Subject: [PATCH] connectivity: treat empty FPIDs as matching in TOPO_MATCH

---
 pcbnew/connectivity/topo_match.cpp | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/pcbnew/connectivity/topo_match.cpp b/pcbnew/connectivity/topo_match.cpp
index 0a63806dc5..8e1a0baf4a 100644
--- a/pcbnew/connectivity/topo_match.cpp
+++ b/pcbnew/connectivity/topo_match.cpp
@@ -536,7 +536,9 @@ COMPONENT::COMPONENT( const wxString& aRef, FOOTPRINT* aParentFp, std::optional<
 
 bool COMPONENT::IsSameKind( const COMPONENT& b ) const
 {
-    return m_prefix == b.m_prefix && m_parentFootprint->GetFPID() == b.m_parentFootprint->GetFPID();
+    return m_prefix == b.m_prefix && 
+    ( (m_parentFootprint->GetFPID() == b.m_parentFootprint->GetFPID() ) || 
+    ( m_parentFootprint->GetFPID().empty() && b.m_parentFootprint->GetFPID().empty() ) );
 }
 
 void COMPONENT::AddPin( PIN* aPin )
@@ -552,12 +554,7 @@ bool COMPONENT::MatchesWith( COMPONENT* b )
         return false;
     }
 
-    if( m_parentFootprint->GetFPID() != b->m_parentFootprint->GetFPID() )
-    {
-        return false;
-    }
-
-    if( m_prefix != b->m_prefix )
+    if( !IsSameKind( *b ) )
     {
         return false;
     }