Make sure segments read from file are in correct order.

Fixes: lp:1752033
* https://bugs.launchpad.net/kicad/+bug/1752033
This commit is contained in:
Jeff Young 2018-04-03 21:57:31 +01:00
parent 7943372e8b
commit 2e4f50f206
2 changed files with 12 additions and 9 deletions

View File

@ -498,15 +498,18 @@ TRACK* TRACK::GetBestInsertPoint( BOARD* aPcb )
{
TRACK* track;
if( Type() == PCB_ZONE_T )
track = aPcb->m_Zone;
else
track = aPcb->m_Track;
// When reading from a file most of the items will already be in the correct order.
// Searching from the back therefore takes us from n^2 to essentially 0.
for( ; track; track = track->Next() )
if( Type() == PCB_ZONE_T )
track = aPcb->m_Zone.GetLast();
else
track = aPcb->m_Track.GetLast();
for( ; track; track = track->Back() )
{
if( GetNetCode() <= track->GetNetCode() )
return track;
if( GetNetCode() >= track->GetNetCode() )
return track->Next();
}
return NULL;

View File

@ -558,11 +558,11 @@ BOARD* PCB_PARSER::parseBOARD_unchecked()
break;
case T_segment:
m_board->Add( parseTRACK(), ADD_APPEND );
m_board->Add( parseTRACK(), ADD_INSERT );
break;
case T_via:
m_board->Add( parseVIA(), ADD_APPEND );
m_board->Add( parseVIA(), ADD_INSERT );
break;
case T_zone: