Move checking for null parent higher.

(Otherwise we set the failure flag without telling the user why.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/15415
This commit is contained in:
Jeff Young 2023-08-18 10:30:03 +01:00
parent 726f09f9ad
commit 6a6e839cc4
3 changed files with 10 additions and 8 deletions

View File

@ -513,11 +513,11 @@ bool ConvertOutlineToPolygon( std::vector<PCB_SHAPE*>& aShapeList, SHAPE_POLY_SE
{
(*aErrorHandler)( _( "(multiple board outlines not supported)" ), a, b,
contours[ contourIndex ].GetPoint( 0 ) );
}
}
return false;
}
}
}
aPolygons.AddOutline( contours[ contourIndex ] );
contourToOutlineIdxMap[ contourIndex ] = aPolygons.OutlineCount() - 1;
@ -563,8 +563,6 @@ bool ConvertOutlineToPolygon( std::vector<PCB_SHAPE*>& aShapeList, SHAPE_POLY_SE
{
BOARD_ITEM* a = fetchOwner( *seg1 );
BOARD_ITEM* b = fetchOwner( *seg2 );
if( a && b )
(*aErrorHandler)( _( "(self-intersecting)" ), a, b, ( *seg1 ).A );
}
@ -577,8 +575,6 @@ bool ConvertOutlineToPolygon( std::vector<PCB_SHAPE*>& aShapeList, SHAPE_POLY_SE
{
BOARD_ITEM* a = fetchOwner( *seg1 );
BOARD_ITEM* b = fetchOwner( *seg2 );
if( a && b )
(*aErrorHandler)( _( "(self-intersecting)" ), a, b, *pt );
}

View File

@ -136,6 +136,9 @@ void DIALOG_FOOTPRINT_CHECKER::runChecks()
OUTLINE_ERROR_HANDLER outlineErrorHandler =
[&]( const wxString& aMsg, BOARD_ITEM* aItemA, BOARD_ITEM* aItemB, const VECTOR2I& aPt )
{
if( !aItemA ) // If we only have a single item, make sure it's A
std::swap( aItemA, aItemB );
errorHandler( aItemA, aItemB, nullptr, DRCE_MALFORMED_COURTYARD, aMsg, aPt );
};

View File

@ -85,6 +85,9 @@ void DRC_TEST_PROVIDER_MISC::testOutline()
OUTLINE_ERROR_HANDLER errorHandler =
[&]( const wxString& msg, BOARD_ITEM* itemA, BOARD_ITEM* itemB, const VECTOR2I& pt )
{
if( !itemA ) // If we only have a single item, make sure it's A
std::swap( itemA, itemB );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_INVALID_OUTLINE );
drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg );