From 6a09cf355124bceba72c11db33eb667ad64c862f Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Wed, 19 Jul 2023 14:24:45 -0700 Subject: [PATCH] Refill legacy zone fills on open Previous check only looked for the existence of a new (as of v6) flag that controlled which strategy we took. Previous versions did not write this flag and so will not hit the check. This works around a missing version bump from when the feature was introduced. --- pcbnew/plugins/kicad/pcb_parser.cpp | 96 +++++++++++++---------------- 1 file changed, 43 insertions(+), 53 deletions(-) diff --git a/pcbnew/plugins/kicad/pcb_parser.cpp b/pcbnew/plugins/kicad/pcb_parser.cpp index 7040971809..9fc935a46b 100644 --- a/pcbnew/plugins/kicad/pcb_parser.cpp +++ b/pcbnew/plugins/kicad/pcb_parser.cpp @@ -2208,33 +2208,8 @@ void PCB_PARSER::parseSetup() break; case T_filled_areas_thickness: - if( parseBool() ) - { - if( m_showLegacy5ZoneWarning ) - { - if( Pgm().IsGUI() && m_queryUserCallback ) - { - // Thick outline fill mode no longer supported. Make sure user is OK with - // converting fills. - if( !m_queryUserCallback( - _( "Legacy Zone Warning" ), wxICON_WARNING, - _( "The legacy zone fill strategy is no longer supported.\n" - "Convert zones to smoothed polygon fills?" ), - _( "Convert" ) ) ) - { - THROW_IO_ERROR( wxT( "CANCEL" ) ); - } - } - else - { - THROW_IO_ERROR( wxT( "Legacy zone fill strategy was found; " - "open the board in the PCB Editor to resolve." ) ); - } - - m_showLegacy5ZoneWarning = false; - } - } - + // Ignore this value, it is not used anymore + parseBool(); NeedRIGHT(); break; @@ -5143,6 +5118,17 @@ ZONE* PCB_PARSER::parseZONE( BOARD_ITEM_CONTAINER* aParent ) zone->SetAssignedPriority( 0 ); + bool isLegacy = false; + + if( m_requiredVersion < 20210606 ) + { + // A new zone fill strategy was added in v6, so we need to know if we're parsing + // a file that was written before that date. Note that the change was implemented as + // a new parameter without changing the version number, so we need to check for the + // presence of the new parameter instead of just the version number. + isLegacy = true; + } + // This is the default for board files: zone->SetIslandRemovalMode( ISLAND_REMOVAL_MODE::ALWAYS ); @@ -5259,33 +5245,9 @@ ZONE* PCB_PARSER::parseZONE( BOARD_ITEM_CONTAINER* aParent ) break; case T_filled_areas_thickness: + if( parseBool() ) - { - if( m_showLegacy5ZoneWarning ) - { - if( Pgm().IsGUI() && m_queryUserCallback ) - { - if( !m_queryUserCallback( - _( "Legacy Zone Warning" ), wxICON_WARNING, - _( "The legacy zone fill strategy is no longer supported.\n" - "Convert zones to smoothed polygon fills?" ), - _( "Convert" ) ) ) - { - THROW_IO_ERROR( wxT( "CANCEL" ) ); - } - } - else - { - THROW_IO_ERROR( wxT( "Legacy zone fill strategy was found; " - "open the board in the PCB Editor to resolve." ) ); - } - - m_showLegacy5ZoneWarning = false; - } - - zone->SetFlags( CANDIDATE ); - dropFilledPolygons = true; - } + isLegacy = true; NeedRIGHT(); break; @@ -5713,6 +5675,34 @@ ZONE* PCB_PARSER::parseZONE( BOARD_ITEM_CONTAINER* aParent ) zone->SetBorderDisplayStyle( hatchStyle, hatchPitch, true ); } + if( isLegacy && !zone->GetIsRuleArea() ) + { + if( m_showLegacy5ZoneWarning ) + { + if( Pgm().IsGUI() && m_queryUserCallback ) + { + if( !m_queryUserCallback( + _( "Legacy Zone Warning" ), wxICON_WARNING, + _( "The legacy zone fill strategy is no longer supported.\n" + "Convert zones to smoothed polygon fills?" ), + _( "Convert" ) ) ) + { + THROW_IO_ERROR( wxT( "CANCEL" ) ); + } + } + else + { + THROW_IO_ERROR( wxT( "Legacy zone fill strategy was found; " + "open the board in the PCB Editor to resolve." ) ); + } + + m_showLegacy5ZoneWarning = false; + } + + zone->SetFlags( CANDIDATE ); + dropFilledPolygons = true; + } + if( addedFilledPolygons && !dropFilledPolygons ) { for( auto& pair : pts )