From dc1ecea4bcc2a7a8ff000c42428f7b704e7b2b25 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 7 Feb 2025 19:47:48 +0100 Subject: [PATCH] OUTSET_ROUTINE::ProcessItem(): handle an exception thrown for incorrect prm. Fixes https://gitlab.com/kicad/code/kicad/-/issues/19880 --- libs/kimath/src/geometry/roundrect.cpp | 9 +++++---- pcbnew/tools/item_modification_routine.cpp | 18 ++++++++++++++---- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/libs/kimath/src/geometry/roundrect.cpp b/libs/kimath/src/geometry/roundrect.cpp index 41cf3c8420..92d308046e 100644 --- a/libs/kimath/src/geometry/roundrect.cpp +++ b/libs/kimath/src/geometry/roundrect.cpp @@ -25,10 +25,11 @@ #include "geometry/roundrect.h" -#include +#include #include #include +#include namespace @@ -55,13 +56,13 @@ ROUNDRECT::ROUNDRECT( SHAPE_RECT aRect, int aRadius ) : { if( m_radius > m_rect.MajorDimension() ) { - throw std::invalid_argument( - "Roundrect radius is larger than the rectangle's major dimension" ); + throw KI_PARAM_ERROR( + _( "Roundrect radius is larger than the rectangle's major dimension" ) ); } if( m_radius < 0 ) { - throw std::invalid_argument( "Roundrect radius must be non-negative" ); + throw KI_PARAM_ERROR( _( "Roundrect radius must be non-negative" ) ); } } diff --git a/pcbnew/tools/item_modification_routine.cpp b/pcbnew/tools/item_modification_routine.cpp index f9ba99d2d5..c529bfed96 100644 --- a/pcbnew/tools/item_modification_routine.cpp +++ b/pcbnew/tools/item_modification_routine.cpp @@ -33,6 +33,8 @@ #include #include #include +#include +#include namespace { @@ -908,10 +910,18 @@ void OUTSET_ROUTINE::ProcessItem( BOARD_ITEM& aItem ) SHAPE_RECT rect( box ); if( m_params.roundCorners ) { - ROUNDRECT rrect( rect, m_params.outsetDistance ); - SHAPE_POLY_SET poly; - rrect.TransformToPolygon( poly, 0, ERROR_LOC::ERROR_OUTSIDE ); - addPoly( poly ); + try + { + ROUNDRECT rrect( rect, m_params.outsetDistance ); + SHAPE_POLY_SET poly; + rrect.TransformToPolygon( poly, 0, ERROR_LOC::ERROR_OUTSIDE ); + addPoly( poly ); + } + catch( const KI_PARAM_ERROR& error ) + { + DisplayErrorMessage( nullptr, error.What() ); + } + } else {