Skip to content

Commit da242ec

Browse files
committed
Trim library layers to instance board before comparing.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/20552
1 parent e64c7a4 commit da242ec

File tree

1 file changed

+30
-15
lines changed

1 file changed

+30
-15
lines changed

pcbnew/drc/drc_test_provider_library_parity.cpp

+30-15
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
2222
*/
2323

24+
#include <layer_range.h>
2425
#include <kiway.h>
2526
#include <macros.h>
2627
#include <netlist_reader/pcb_netlist.h>
@@ -126,6 +127,17 @@ class DRC_TEST_PROVIDER_LIBRARY_PARITY : public DRC_TEST_PROVIDER
126127
UNITS_PROVIDER g_unitsProvider( pcbIUScale, EDA_UNITS::MM );
127128

128129

130+
LSET getBoardNormalizedLayerSet( const BOARD_ITEM* aLibItem, const BOARD* aBoard )
131+
{
132+
LSET lset = aLibItem->GetLayerSet();
133+
134+
if( aBoard )
135+
lset &= aBoard->GetEnabledLayers();
136+
137+
return lset;
138+
}
139+
140+
129141
bool primitiveNeedsUpdate( const std::shared_ptr<PCB_SHAPE>& a,
130142
const std::shared_ptr<PCB_SHAPE>& b )
131143
{
@@ -285,12 +297,7 @@ bool padNeedsUpdate( const PAD* a, const PAD* b, REPORTER* aReporter )
285297
if( a->GetRemoveUnconnected() )
286298
layerSettingsDiffer |= a->GetKeepTopBottom() != b->GetKeepTopBottom();
287299

288-
// Trim layersets to the current board before comparing
289-
LSET enabledLayers = a->GetBoard() ? a->GetBoard()->GetEnabledLayers() : LSET::AllLayersMask();
290-
LSET aLayers = a->GetLayerSet() & enabledLayers;
291-
LSET bLayers = b->GetLayerSet() & enabledLayers;
292-
293-
if( layerSettingsDiffer || aLayers != bLayers )
300+
if( layerSettingsDiffer || a->GetLayerSet() != getBoardNormalizedLayerSet( b, a->GetBoard() ) )
294301
{
295302
diff = true;
296303

@@ -319,34 +326,42 @@ bool padNeedsUpdate( const PAD* a, const PAD* b, REPORTER* aReporter )
319326
layerName = board ? board->GetLayerName( layer ) : LayerName( layer );
320327

321328
TEST( a->GetShape( layer ), b->GetShape( layer ),
322-
wxString::Format( _( "%s pad shape type differs on layer %s." ), PAD_DESC( a ),
323-
layerName ) );
329+
wxString::Format( _( "%s pad shape type differs on layer %s." ),
330+
PAD_DESC( a ),
331+
layerName ) );
324332

325333
TEST( a->GetSize( layer ), b->GetSize( layer ),
326-
wxString::Format( _( "%s size differs on layer %s." ), PAD_DESC( a ), layerName ) );
334+
wxString::Format( _( "%s size differs on layer %s." ),
335+
PAD_DESC( a ),
336+
layerName ) );
327337

328338
TEST( a->GetDelta( layer ), b->GetDelta( layer ),
329-
wxString::Format( _( "%s trapezoid delta differs on layer %s." ), PAD_DESC( a ),
339+
wxString::Format( _( "%s trapezoid delta differs on layer %s." ),
340+
PAD_DESC( a ),
330341
layerName ) );
331342

332343
TEST_D( a->GetRoundRectRadiusRatio( layer ),
333344
b->GetRoundRectRadiusRatio( layer ),
334-
wxString::Format( _( "%s rounded corners differ on layer %s." ), PAD_DESC( a ),
345+
wxString::Format( _( "%s rounded corners differ on layer %s." ),
346+
PAD_DESC( a ),
335347
layerName ) );
336348

337349
TEST_D( a->GetChamferRectRatio( layer ),
338350
b->GetChamferRectRatio( layer ),
339351
wxString::Format( _( "%s chamfered corner sizes differ on layer %s." ),
340-
PAD_DESC( a ), layerName ) );
352+
PAD_DESC( a ),
353+
layerName ) );
341354

342355
TEST( a->GetChamferPositions( layer ),
343356
b->GetChamferPositions( layer ),
344-
wxString::Format( _( "%s chamfered corners differ on layer %s." ), PAD_DESC( a ),
357+
wxString::Format( _( "%s chamfered corners differ on layer %s." ),
358+
PAD_DESC( a ),
345359
layerName ) );
346360

347361
TEST_PT( a->GetOffset( layer ), b->GetOffset( layer ),
348362
wxString::Format( _( "%s shape offset from hole differs on layer %s." ),
349-
PAD_DESC( a ), layerName ) );
363+
PAD_DESC( a ),
364+
layerName ) );
350365
}
351366

352367
TEST( a->GetDrillShape(), b->GetDrillShape(),
@@ -509,7 +524,7 @@ bool zoneNeedsUpdate( const ZONE* a, const ZONE* b, REPORTER* aReporter )
509524
TEST( a->GetDoNotAllowVias(), b->GetDoNotAllowVias(),
510525
wxString::Format( _( "%s keep out vias setting differs." ), ITEM_DESC( a ) ) );
511526

512-
TEST( a->GetLayerSet(), b->GetLayerSet(),
527+
TEST( a->GetLayerSet(), getBoardNormalizedLayerSet( b, a->GetBoard() ),
513528
wxString::Format( _( "%s layers differ." ), ITEM_DESC( a ) ) );
514529

515530
TEST( a->GetPadConnection(), b->GetPadConnection(),

0 commit comments

Comments
 (0)