Browse Source

Temporary patches around LSET and negative layers

Probably this should be replaced with a less error-prone
approach.  Right now the LSET -> BASE_SET system is risky
because it is converting a signed enum (PCB_LAYER_ID) to
a size_t in all the underlying operations.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/18738
jobs
Jon Evans 1 year ago
parent
commit
4e7fcb3b67
  1. 17
      common/lset.cpp
  2. 4
      include/lset.h

17
common/lset.cpp

@ -45,7 +45,10 @@ LSET::LSET( std::initializer_list<PCB_LAYER_ID> aList ) :
LSET()
{
for( PCB_LAYER_ID layer : aList )
set( layer );
{
if( layer > 0 )
set( layer );
}
}
@ -53,14 +56,20 @@ LSET::LSET( const LSEQ& aSeq ) :
LSET()
{
for( PCB_LAYER_ID layer : aSeq )
set( layer );
{
if( layer > 0 )
set( layer );
}
}
LSET::LSET( const LAYER_RANGE& aRange )
{
for( PCB_LAYER_ID layer : aRange )
set( layer );
{
if( layer > 0 )
set( layer );
}
}
@ -966,4 +975,4 @@ LSET::non_copper_layers_iterator LSET::non_copper_layers_end() const
}
#endif
#endif

4
include/lset.h

@ -59,6 +59,10 @@ public:
*/
bool Contains( PCB_LAYER_ID aLayer )
{
// At the moment, LSET cannot store negative layers, but PCB_LAYER_ID can contain them
if( aLayer < 0 )
return false;
try
{
return test( aLayer );

Loading…
Cancel
Save