File Trim-library-layers-to-instance-board-before-compari.patch of Package kicad.8

From f235954fc05fb81969fbe3d4d213ec1666581571 Mon Sep 17 00:00:00 2001
From: Jeff Young <jeff@rokeby.ie>
Date: Tue, 6 May 2025 17:54:00 +0100
Subject: [PATCH 2/2] Trim library layers to instance board before comparing.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/20552

(cherry picked from commit da242ec3f3ab72efb8b9d0fc76568c61c1cb1e91)
---
 .../drc/drc_test_provider_library_parity.cpp  | 21 ++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/pcbnew/drc/drc_test_provider_library_parity.cpp b/pcbnew/drc/drc_test_provider_library_parity.cpp
index 2693854a9e..c9dd3951c7 100644
--- a/pcbnew/drc/drc_test_provider_library_parity.cpp
+++ b/pcbnew/drc/drc_test_provider_library_parity.cpp
@@ -21,6 +21,7 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
  */
 
+#include <layer_range.h>
 #include <kiway.h>
 #include <macros.h>
 #include <netlist_reader/pcb_netlist.h>
@@ -126,6 +127,17 @@ public:
 UNITS_PROVIDER g_unitsProvider( pcbIUScale, EDA_UNITS::MILLIMETRES );
 
 
+LSET getBoardNormalizedLayerSet( const BOARD_ITEM* aLibItem, const BOARD* aBoard )
+{
+    LSET lset = aLibItem->GetLayerSet();
+
+    if( aBoard )
+        lset &= aBoard->GetEnabledLayers();
+
+    return lset;
+}
+
+
 bool primitiveNeedsUpdate( const std::shared_ptr<PCB_SHAPE>& a,
                            const std::shared_ptr<PCB_SHAPE>& b )
 {
@@ -242,12 +254,7 @@ bool padNeedsUpdate( const PAD* a, const PAD* b, REPORTER* aReporter )
     if( a->GetRemoveUnconnected() )
         layerSettingsDiffer |= a->GetKeepTopBottom() != b->GetKeepTopBottom();
 
-    // Trim layersets to the current board before comparing
-    LSET enabledLayers = a->GetBoard() ? a->GetBoard()->GetEnabledLayers() : LSET::AllLayersMask();
-    LSET aLayers = a->GetLayerSet() & enabledLayers;
-    LSET bLayers = b->GetLayerSet() & enabledLayers;
-
-    if( layerSettingsDiffer || aLayers != bLayers )
+    if( layerSettingsDiffer || a->GetLayerSet() != getBoardNormalizedLayerSet( b, a->GetBoard() ) )
     {
         diff = true;
 
@@ -433,7 +440,7 @@ bool zoneNeedsUpdate( const ZONE* a, const ZONE* b, REPORTER* aReporter )
     TEST( a->GetDoNotAllowVias(), b->GetDoNotAllowVias(),
           wxString::Format( _( "%s keep out vias setting differs." ), ITEM_DESC( a ) ) );
 
-    TEST( a->GetLayerSet(), b->GetLayerSet(),
+    TEST( a->GetLayerSet(), getBoardNormalizedLayerSet( b, a->GetBoard() ),
           wxString::Format( _( "%s layers differ." ), ITEM_DESC( a ) ) );
 
     TEST( a->GetPadConnection(), b->GetPadConnection(),
-- 
2.47.1

openSUSE Build Service is sponsored by