Be more responsive to cancel when filling zones.

Fixes https://gitlab.com/kicad/code/kicad/issues/6077
This commit is contained in:
Jeff Young 2020-10-26 12:54:30 +00:00
parent 09af6c78bb
commit 397f3d07db
2 changed files with 44 additions and 2 deletions

View File

@ -226,7 +226,9 @@ void CN_CONNECTIVITY_ALGO::searchConnections()
if( m_progressReporter ) if( m_progressReporter )
{ {
m_progressReporter->SetMaxProgress( dirtyItems.size() ); m_progressReporter->SetMaxProgress( dirtyItems.size() );
m_progressReporter->KeepRefreshing();
if( !m_progressReporter->KeepRefreshing() )
return;
} }
if( m_itemList.IsDirty() ) if( m_itemList.IsDirty() )
@ -247,7 +249,12 @@ void CN_CONNECTIVITY_ALGO::searchConnections()
aItemList->FindNearby( dirtyItems[i], visitor ); aItemList->FindNearby( dirtyItems[i], visitor );
if( aReporter ) if( aReporter )
aReporter->AdvanceProgress(); {
if( aReporter->IsCancelled() )
break;
else
aReporter->AdvanceProgress();
}
} }
return 1; 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 ); std::for_each( m_itemList.begin(), m_itemList.end(), addToSearchList );
if( m_progressReporter && m_progressReporter->IsCancelled() )
return CLUSTERS();
while( !item_set.empty() ) while( !item_set.empty() )
{ {
CN_CLUSTER_PTR cluster ( new CN_CLUSTER() ); 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 ); clusters.push_back( cluster );
} }
if( m_progressReporter && m_progressReporter->IsCancelled() )
return CLUSTERS();
std::sort( clusters.begin(), clusters.end(), std::sort( clusters.begin(), clusters.end(),
[]( CN_CLUSTER_PTR a, CN_CLUSTER_PTR b ) []( CN_CLUSTER_PTR a, CN_CLUSTER_PTR b )

View File

@ -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, void ZONE_FILLER::buildCopperItemClearances( const ZONE_CONTAINER* aZone, PCB_LAYER_ID aLayer,
SHAPE_POLY_SET& aHoles ) 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; static PCB_SHAPE dummyEdge;
dummyEdge.SetParent( m_board ); dummyEdge.SetParent( m_board );
dummyEdge.SetLayer( Edge_Cuts ); dummyEdge.SetLayer( Edge_Cuts );
@ -758,6 +766,9 @@ void ZONE_FILLER::buildCopperItemClearances( const ZONE_CONTAINER* aZone, PCB_LA
{ {
for( D_PAD* pad : module->Pads() ) for( D_PAD* pad : module->Pads() )
{ {
if( checkForCancel( m_progressReporter ) )
return;
if( !pad->FlashLayer( aLayer ) ) if( !pad->FlashLayer( aLayer ) )
{ {
if( pad->GetDrillSize().x == 0 && pad->GetDrillSize().y == 0 ) 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) ) if( track->GetNetCode() == aZone->GetNetCode() && ( aZone->GetNetCode() != 0) )
continue; continue;
if( checkForCancel( m_progressReporter ) )
return;
knockoutTrack( track ); knockoutTrack( track );
} }
@ -853,11 +867,21 @@ void ZONE_FILLER::buildCopperItemClearances( const ZONE_CONTAINER* aZone, PCB_LA
knockoutGraphic( &module->Value() ); knockoutGraphic( &module->Value() );
for( BOARD_ITEM* item : module->GraphicalItems() ) for( BOARD_ITEM* item : module->GraphicalItems() )
{
if( checkForCancel( m_progressReporter ) )
return;
knockoutGraphic( item ); knockoutGraphic( item );
}
} }
for( BOARD_ITEM* item : m_board->Drawings() ) for( BOARD_ITEM* item : m_board->Drawings() )
{
if( checkForCancel( m_progressReporter ) )
return;
knockoutGraphic( item ); knockoutGraphic( item );
}
// Add non-connected zone clearances // 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() ) for( ZONE_CONTAINER* otherZone : m_board->Zones() )
{ {
if( checkForCancel( m_progressReporter ) )
return;
if( otherZone->GetNetCode() != aZone->GetNetCode() if( otherZone->GetNetCode() != aZone->GetNetCode()
&& otherZone->GetPriority() > aZone->GetPriority() ) && otherZone->GetPriority() > aZone->GetPriority() )
{ {
@ -915,6 +942,9 @@ void ZONE_FILLER::buildCopperItemClearances( const ZONE_CONTAINER* aZone, PCB_LA
{ {
for( ZONE_CONTAINER* otherZone : module->Zones() ) for( ZONE_CONTAINER* otherZone : module->Zones() )
{ {
if( checkForCancel( m_progressReporter ) )
return;
if( otherZone->GetNetCode() != aZone->GetNetCode() if( otherZone->GetNetCode() != aZone->GetNetCode()
&& otherZone->GetPriority() > aZone->GetPriority() ) && otherZone->GetPriority() > aZone->GetPriority() )
{ {