From 877a65dcc794ba9bf8ae3cab729cea24a5a7eed7 Mon Sep 17 00:00:00 2001 From: Julius Schmidt Date: Tue, 14 Feb 2017 00:38:14 +0100 Subject: [PATCH] Fix ratsnest calculation for pads connected with zones (GAL) This patch fixes a problem with GAL where zones are ignored in ratsnest calculation. The problem is that calling RN_DATA::Update on a zone with no polygons (an unfilled zone) will remove the zone successfully, but then RN_DATA::Add is a no-op. From this point on, because ::Update refuses to work on items that have not been ::Add'ed, the zone is removed entirely from ratsnest calculation and will only be reconsidered once it is explicitly ::Add'ed again. The fix is to explicitly create an empty RN_ZONE_DATA object for every zone that is ::Add'ed. A second problem is that the point editor forgot to call RN_DATA::Recalculate after calling Fill_Zone. Fixes: lp:1537120 * https://bugs.launchpad.net/kicad/+bug/1537120 --- pcbnew/ratsnest_data.cpp | 3 +++ pcbnew/tools/point_editor.cpp | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/pcbnew/ratsnest_data.cpp b/pcbnew/ratsnest_data.cpp index ea9055088f..b2e1f4da28 100644 --- a/pcbnew/ratsnest_data.cpp +++ b/pcbnew/ratsnest_data.cpp @@ -499,6 +499,9 @@ bool RN_NET::AddItem( const ZONE_CONTAINER* aZone ) // Prepare a list of polygons (every zone can contain one or more polygons) const SHAPE_POLY_SET& polySet = aZone->GetFilledPolysList(); + // This ensures that we record aZone as added even if it contains no polygons. + (void) m_zones[aZone]; + for( int i = 0; i < polySet.OutlineCount(); ++i ) { const SHAPE_LINE_CHAIN& path = polySet.COutline( i ); diff --git a/pcbnew/tools/point_editor.cpp b/pcbnew/tools/point_editor.cpp index dcb58482e3..40088e9e9c 100644 --- a/pcbnew/tools/point_editor.cpp +++ b/pcbnew/tools/point_editor.cpp @@ -42,6 +42,7 @@ using namespace std::placeholders; #include #include #include +#include // Few constants to avoid using bare numbers for point indices enum SEG_POINTS @@ -523,7 +524,10 @@ void POINT_EDITOR::finishItem() const ZONE_CONTAINER* zone = static_cast( item ); if( zone->IsFilled() ) + { getEditFrame()->Fill_Zone( zone ); + zone->GetBoard()->GetRatsnest()->Recalculate( zone->GetNetCode() ); + } } }