7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-11 14:59:50 +00:00

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
This commit is contained in:
Jon Evans 2024-09-18 18:36:17 -04:00
parent 01e6b6a9f9
commit 4e7fcb3b67
2 changed files with 17 additions and 4 deletions
common
include

View File

@ -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

View File

@ -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 );