From b6efb88ee97395c2d0b029459eca3c3f54a2a4db Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 29 Sep 2022 17:45:59 +0100 Subject: [PATCH] Fix logic error when filling zones. Fixes https://gitlab.com/kicad/code/kicad/issues/12542 --- pcbnew/pcb_expr_evaluator.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/pcbnew/pcb_expr_evaluator.cpp b/pcbnew/pcb_expr_evaluator.cpp index 5442b2dcdc..78636c3c24 100644 --- a/pcbnew/pcb_expr_evaluator.cpp +++ b/pcbnew/pcb_expr_evaluator.cpp @@ -714,13 +714,23 @@ static void enclosedByAreaFunc( LIBEVAL::CONTEXT* aCtx, void* self ) return i->second; SHAPE_POLY_SET itemShape; + bool enclosedByArea; item->TransformShapeWithClearanceToPolygon( itemShape, layer, 0, maxError, ERROR_OUTSIDE ); - itemShape.BooleanSubtract( *aArea->Outline(), SHAPE_POLY_SET::PM_FAST ); - - bool enclosedByArea = itemShape.IsEmpty(); + if( itemShape.IsEmpty() ) + { + // If it's already empty then our test will have no meaning. + enclosedByArea = false; + } + else + { + itemShape.BooleanSubtract( *aArea->Outline(), + SHAPE_POLY_SET::PM_FAST ); + + enclosedByArea = itemShape.IsEmpty(); + } board->m_EnclosedByAreaCache[ key ] = enclosedByArea;