diff --git a/pcbnew/connectivity/connectivity_algo.cpp b/pcbnew/connectivity/connectivity_algo.cpp index bca1e6ca38..fba349a134 100644 --- a/pcbnew/connectivity/connectivity_algo.cpp +++ b/pcbnew/connectivity/connectivity_algo.cpp @@ -226,7 +226,9 @@ void CN_CONNECTIVITY_ALGO::searchConnections() if( m_progressReporter ) { m_progressReporter->SetMaxProgress( dirtyItems.size() ); - m_progressReporter->KeepRefreshing(); + + if( !m_progressReporter->KeepRefreshing() ) + return; } if( m_itemList.IsDirty() ) @@ -247,7 +249,12 @@ void CN_CONNECTIVITY_ALGO::searchConnections() aItemList->FindNearby( dirtyItems[i], visitor ); if( aReporter ) - aReporter->AdvanceProgress(); + { + if( aReporter->IsCancelled() ) + break; + else + aReporter->AdvanceProgress(); + } } return 1; @@ -350,6 +357,9 @@ const CN_CONNECTIVITY_ALGO::CLUSTERS CN_CONNECTIVITY_ALGO::SearchClusters( CLUST std::for_each( m_itemList.begin(), m_itemList.end(), addToSearchList ); + if( m_progressReporter && m_progressReporter->IsCancelled() ) + return CLUSTERS(); + while( !item_set.empty() ) { CN_CLUSTER_PTR cluster ( new CN_CLUSTER() ); @@ -391,6 +401,8 @@ const CN_CONNECTIVITY_ALGO::CLUSTERS CN_CONNECTIVITY_ALGO::SearchClusters( CLUST clusters.push_back( cluster ); } + if( m_progressReporter && m_progressReporter->IsCancelled() ) + return CLUSTERS(); std::sort( clusters.begin(), clusters.end(), []( CN_CLUSTER_PTR a, CN_CLUSTER_PTR b ) diff --git a/pcbnew/zone_filler.cpp b/pcbnew/zone_filler.cpp index bfbfa9922e..31fbd774f6 100644 --- a/pcbnew/zone_filler.cpp +++ b/pcbnew/zone_filler.cpp @@ -696,6 +696,14 @@ void ZONE_FILLER::knockoutThermalReliefs( const ZONE_CONTAINER* aZone, PCB_LAYER void ZONE_FILLER::buildCopperItemClearances( const ZONE_CONTAINER* aZone, PCB_LAYER_ID aLayer, SHAPE_POLY_SET& aHoles ) { + long ticker = 0; + + auto checkForCancel = + [&ticker]( PROGRESS_REPORTER* aReporter ) -> bool + { + return aReporter && ( ticker++ % 50 ) == 0 && aReporter->IsCancelled(); + }; + static PCB_SHAPE dummyEdge; dummyEdge.SetParent( m_board ); dummyEdge.SetLayer( Edge_Cuts ); @@ -758,6 +766,9 @@ void ZONE_FILLER::buildCopperItemClearances( const ZONE_CONTAINER* aZone, PCB_LA { for( D_PAD* pad : module->Pads() ) { + if( checkForCancel( m_progressReporter ) ) + return; + if( !pad->FlashLayer( aLayer ) ) { if( pad->GetDrillSize().x == 0 && pad->GetDrillSize().y == 0 ) @@ -819,6 +830,9 @@ void ZONE_FILLER::buildCopperItemClearances( const ZONE_CONTAINER* aZone, PCB_LA if( track->GetNetCode() == aZone->GetNetCode() && ( aZone->GetNetCode() != 0) ) continue; + if( checkForCancel( m_progressReporter ) ) + return; + knockoutTrack( track ); } @@ -853,11 +867,21 @@ void ZONE_FILLER::buildCopperItemClearances( const ZONE_CONTAINER* aZone, PCB_LA knockoutGraphic( &module->Value() ); for( BOARD_ITEM* item : module->GraphicalItems() ) + { + if( checkForCancel( m_progressReporter ) ) + return; + knockoutGraphic( item ); + } } for( BOARD_ITEM* item : m_board->Drawings() ) + { + if( checkForCancel( m_progressReporter ) ) + return; + knockoutGraphic( item ); + } // Add non-connected zone clearances // @@ -900,6 +924,9 @@ void ZONE_FILLER::buildCopperItemClearances( const ZONE_CONTAINER* aZone, PCB_LA for( ZONE_CONTAINER* otherZone : m_board->Zones() ) { + if( checkForCancel( m_progressReporter ) ) + return; + if( otherZone->GetNetCode() != aZone->GetNetCode() && otherZone->GetPriority() > aZone->GetPriority() ) { @@ -915,6 +942,9 @@ void ZONE_FILLER::buildCopperItemClearances( const ZONE_CONTAINER* aZone, PCB_LA { for( ZONE_CONTAINER* otherZone : module->Zones() ) { + if( checkForCancel( m_progressReporter ) ) + return; + if( otherZone->GetNetCode() != aZone->GetNetCode() && otherZone->GetPriority() > aZone->GetPriority() ) {