From ea387f2f28ed43ce0d48abd346675e80f281d37c Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 8 Oct 2020 20:21:24 +0100 Subject: [PATCH] Don't segfault after doing a cutout which removes entire zone. Fixes https://gitlab.com/kicad/code/kicad/issues/5532 --- pcbnew/tools/zone_create_helper.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pcbnew/tools/zone_create_helper.cpp b/pcbnew/tools/zone_create_helper.cpp index 984a03c386..49690d1923 100644 --- a/pcbnew/tools/zone_create_helper.cpp +++ b/pcbnew/tools/zone_create_helper.cpp @@ -168,6 +168,7 @@ void ZONE_CREATE_HELPER::performZoneCutout( ZONE_CONTAINER& aZone, ZONE_CONTAINE commit.Remove( &aZone ); ZONE_FILLER filler( board, &commit ); + if( !filler.Fill( newZones ) ) { commit.Revert(); @@ -177,8 +178,15 @@ void ZONE_CREATE_HELPER::performZoneCutout( ZONE_CONTAINER& aZone, ZONE_CONTAINE commit.Push( _( "Add a zone cutout" ) ); // Select the new zone and set it as the source for the next cutout - toolMgr->RunAction( PCB_ACTIONS::selectItem, true, newZones[0] ); - m_params.m_sourceZone = newZones[0]; + if( newZones.empty() ) + { + m_params.m_sourceZone = nullptr; + } + else + { + m_params.m_sourceZone = newZones[0]; + toolMgr->RunAction( PCB_ACTIONS::selectItem, true, newZones[0] ); + } }