Fix broken logic in ImportSizes().

Fixes https://gitlab.com/kicad/code/kicad/issues/6049
This commit is contained in:
Jeff Young 2020-10-18 11:54:28 +01:00
parent 6ce803b77c
commit 02cbcb99df
3 changed files with 17 additions and 11 deletions

View File

@ -312,7 +312,7 @@ int PNS_PCBNEW_RULE_RESOLVER::Clearance( const PNS::ITEM* aA, const PNS::ITEM* a
}
int PNS_KICAD_IFACE_BASE::inheritTrackWidth( PNS::ITEM* aItem )
bool PNS_KICAD_IFACE_BASE::inheritTrackWidth( PNS::ITEM* aItem, int* aInheritedWidth )
{
VECTOR2I p;
@ -329,10 +329,11 @@ int PNS_KICAD_IFACE_BASE::inheritTrackWidth( PNS::ITEM* aItem )
break;
case PNS::ITEM::SEGMENT_T:
return static_cast<PNS::SEGMENT*>( aItem )->Width();
*aInheritedWidth = static_cast<PNS::SEGMENT*>( aItem )->Width();
return true;
default:
return 0;
return false;
}
PNS::JOINT* jt = static_cast<PNS::NODE*>( aItem->Owner() )->FindJoint( p, aItem );
@ -341,7 +342,6 @@ int PNS_KICAD_IFACE_BASE::inheritTrackWidth( PNS::ITEM* aItem )
int mval = INT_MAX;
PNS::ITEM_SET linkedSegs = jt->Links();
linkedSegs.ExcludeItem( aItem ).FilterKinds( PNS::ITEM::SEGMENT_T );
@ -351,7 +351,11 @@ int PNS_KICAD_IFACE_BASE::inheritTrackWidth( PNS::ITEM* aItem )
mval = std::min( w, mval );
}
return ( mval == INT_MAX ? 0 : mval );
if( mval == INT_MAX )
return false;
*aInheritedWidth = mval;
return true;
}
@ -361,22 +365,24 @@ bool PNS_KICAD_IFACE_BASE::ImportSizes( PNS::SIZES_SETTINGS& aSizes, PNS::ITEM*
PNS::CONSTRAINT constraint;
int trackWidth = bds.m_TrackMinWidth;
bool found = false;
if( bds.m_UseConnectedTrackWidth && aStartItem != nullptr )
{
trackWidth = inheritTrackWidth( aStartItem );
found = inheritTrackWidth( aStartItem, &trackWidth );
}
if( trackWidth == 0 && bds.UseNetClassTrack() && aStartItem ) // netclass value
if( !found && bds.UseNetClassTrack() && aStartItem )
{
if( m_ruleResolver->QueryConstraint( PNS::CONSTRAINT_TYPE::CT_WIDTH, aStartItem, nullptr,
aStartItem->Layer(), &constraint ) )
{
trackWidth = constraint.m_Value.OptThenMin();
found = true; // Note: allowed to override anything, including bds.m_TrackMinWidth
}
}
if( trackWidth == 0 )
if( !found )
{
trackWidth = bds.GetCurrentTrackWidth();
}

View File

@ -96,7 +96,7 @@ protected:
bool syncTextItem( PNS::NODE* aWorld, EDA_TEXT* aText, PCB_LAYER_ID aLayer );
bool syncGraphicalItem( PNS::NODE* aWorld, PCB_SHAPE* aItem );
bool syncZone( PNS::NODE* aWorld, ZONE_CONTAINER* aZone, SHAPE_POLY_SET* aBoardOutline );
int inheritTrackWidth( PNS::ITEM* aItem );
bool inheritTrackWidth( PNS::ITEM* aItem, int* aInheritedWidth );
PNS::NODE* m_world;

View File

@ -101,7 +101,7 @@ public:
private:
int inheritTrackWidth( ITEM* aItem );
bool inheritTrackWidth( ITEM* aItem, int* aInheritedWidth );
int m_trackWidth;
int m_diffPairWidth;