Move zone out-of-date check to the right place.

Fixes: lp:1760097
* https://bugs.launchpad.net/kicad/+bug/1760097
This commit is contained in:
Jeff Young 2018-04-09 15:07:53 +01:00
parent 4b0d477c76
commit 05dae96275
3 changed files with 18 additions and 12 deletions

View File

@ -34,6 +34,8 @@
#include <memory> #include <memory>
#include <math/vector2d.h> #include <math/vector2d.h>
#include <geometry/shape_poly_set.h>
#include <class_zone.h>
class CN_CLUSTER; class CN_CLUSTER;
class CN_CONNECTIVITY_ALGO; class CN_CONNECTIVITY_ALGO;
@ -57,8 +59,14 @@ struct CN_DISJOINT_NET_ENTRY
struct CN_ZONE_ISOLATED_ISLAND_LIST struct CN_ZONE_ISOLATED_ISLAND_LIST
{ {
ZONE_CONTAINER *m_zone; CN_ZONE_ISOLATED_ISLAND_LIST( ZONE_CONTAINER* aZone ) :
std::vector<int> m_islands; m_zone( aZone ),
m_lastPolys( aZone->GetFilledPolysList() )
{}
ZONE_CONTAINER* m_zone;
const SHAPE_POLY_SET m_lastPolys;
std::vector<int> m_islands;
}; };
struct RN_DYNAMIC_LINE struct RN_DYNAMIC_LINE

View File

@ -97,9 +97,7 @@ void ZONE_FILLER::Fill( std::vector<ZONE_CONTAINER*> aZones, bool aCheck )
if( zone->GetIsKeepout() ) if( zone->GetIsKeepout() )
continue; continue;
CN_ZONE_ISOLATED_ISLAND_LIST l; toFill.emplace_back( CN_ZONE_ISOLATED_ISLAND_LIST(zone) );
l.m_zone = zone;
toFill.push_back( l );
} }
for( unsigned i = 0; i < toFill.size(); i++ ) for( unsigned i = 0; i < toFill.size(); i++ )
@ -117,7 +115,6 @@ void ZONE_FILLER::Fill( std::vector<ZONE_CONTAINER*> aZones, bool aCheck )
} }
m_next = 0; m_next = 0;
m_out_of_date = false;
m_count_done = 0; m_count_done = 0;
std::vector<std::thread> fillWorkers; std::vector<std::thread> fillWorkers;
@ -132,9 +129,6 @@ void ZONE_FILLER::Fill( std::vector<ZONE_CONTAINER*> aZones, bool aCheck )
ZONE_CONTAINER* zone = toFill[i].m_zone; ZONE_CONTAINER* zone = toFill[i].m_zone;
fillSingleZone( zone, rawPolys, finalPolys ); fillSingleZone( zone, rawPolys, finalPolys );
if( aCheck && zone->GetFilledPolysList().GetHash() != finalPolys.GetHash() )
m_out_of_date.store( true );
zone->SetRawPolysList( rawPolys ); zone->SetRawPolysList( rawPolys );
zone->SetFilledPolysList( finalPolys ); zone->SetFilledPolysList( finalPolys );
zone->SetIsFilled( true ); zone->SetIsFilled( true );
@ -170,6 +164,8 @@ void ZONE_FILLER::Fill( std::vector<ZONE_CONTAINER*> aZones, bool aCheck )
connectivity->SetProgressReporter( m_progressReporter ); connectivity->SetProgressReporter( m_progressReporter );
connectivity->FindIsolatedCopperIslands( toFill ); connectivity->FindIsolatedCopperIslands( toFill );
bool outOfDate = false;
for( auto& zone : toFill ) for( auto& zone : toFill )
{ {
std::sort( zone.m_islands.begin(), zone.m_islands.end(), std::greater<int>() ); std::sort( zone.m_islands.begin(), zone.m_islands.end(), std::greater<int>() );
@ -181,11 +177,14 @@ void ZONE_FILLER::Fill( std::vector<ZONE_CONTAINER*> aZones, bool aCheck )
} }
zone.m_zone->SetFilledPolysList( poly ); zone.m_zone->SetFilledPolysList( poly );
if( aCheck && zone.m_lastPolys.GetHash() != poly.GetHash() )
outOfDate = true;
} }
if( aCheck && m_out_of_date ) if( aCheck && outOfDate )
{ {
bool cancel = !IsOK( nullptr, _( "Zone fills may be out-of-date. Re-fill all zones?" ) ); bool cancel = !IsOK( nullptr, _( "Zone fills are out-of-date. Re-fill?" ) );
if( m_progressReporter ) if( m_progressReporter )
{ {

View File

@ -122,7 +122,6 @@ private:
std::atomic_size_t m_next; // An index into the vector of zones to fill. std::atomic_size_t m_next; // An index into the vector of zones to fill.
// Used by the variuos parallel thread sets during // Used by the variuos parallel thread sets during
// fill operations. // fill operations.
std::atomic_bool m_out_of_date;
std::atomic_size_t m_count_done; std::atomic_size_t m_count_done;
}; };