diff --git a/include/page_info.h b/include/page_info.h index aa0631cbc1..aec47754b3 100644 --- a/include/page_info.h +++ b/include/page_info.h @@ -3,7 +3,7 @@ * * Copyright (C) 2007-2013 SoftPLC Corporation, Dick Hollenbeck * Copyright (C) 2008-2013 Wayne Stambaugh - * Copyright (C) 2007-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2007-2022 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -36,7 +36,7 @@ #include // for IU_PER_MILS /// Min and max page sizes for clamping, in mils. -#define MIN_PAGE_SIZE_MILS 100 +#define MIN_PAGE_SIZE_MILS 1000 #define MAX_PAGE_SIZE_PCBNEW_MILS 48000 #define MAX_PAGE_SIZE_EESCHEMA_MILS 120000 diff --git a/pcbnew/plugins/kicad/pcb_parser.cpp b/pcbnew/plugins/kicad/pcb_parser.cpp index c7cdd4440b..ec8bb4b66f 100644 --- a/pcbnew/plugins/kicad/pcb_parser.cpp +++ b/pcbnew/plugins/kicad/pcb_parser.cpp @@ -1196,18 +1196,20 @@ void PCB_PARSER::parsePAGE_INFO() { double width = parseDouble( "width" ); // width in mm + const double Mils2mm = 0.0254; + // Perform some controls to avoid crashes if the size is edited by hands - if( width < 100.0 ) - width = 100.0; - else if( width > 1200.0 ) - width = 1200.0; + if( width < MIN_PAGE_SIZE_MILS*Mils2mm ) + width = MIN_PAGE_SIZE_MILS*Mils2mm; + else if( width > MAX_PAGE_SIZE_PCBNEW_MILS*Mils2mm ) + width = MAX_PAGE_SIZE_PCBNEW_MILS*Mils2mm; double height = parseDouble( "height" ); // height in mm - if( height < 100.0 ) - height = 100.0; - else if( height > 1200.0 ) - height = 1200.0; + if( height < MIN_PAGE_SIZE_MILS*Mils2mm ) + height = MIN_PAGE_SIZE_MILS*Mils2mm; + else if( height > MAX_PAGE_SIZE_PCBNEW_MILS*Mils2mm ) + height = MAX_PAGE_SIZE_PCBNEW_MILS*Mils2mm; pageInfo.SetWidthMils( Mm2mils( width ) ); pageInfo.SetHeightMils( Mm2mils( height ) );