PCBNew: Fix crash while routing in Legacy canvas

it was due to a incorrect behavior of TRACK::GetBestInsertPoint( BOARD* aPcb )
Also: update comment for this method.

Fixes: lp:1767061
https://bugs.launchpad.net/kicad/+bug/1767061
This commit is contained in:
jean-pierre charras 2018-04-26 19:42:39 +02:00
parent 7a923ab969
commit 641c8bb548
2 changed files with 9 additions and 3 deletions

View File

@ -512,7 +512,10 @@ TRACK* TRACK::GetBestInsertPoint( BOARD* aPcb )
return track->Next();
}
return NULL;
if( Type() == PCB_ZONE_T )
return aPcb->m_Zone.GetFirst();
else
return aPcb->m_Track.GetFirst();
}

View File

@ -147,10 +147,13 @@ public:
/**
* Function GetBestInsertPoint
* searches the "best" insertion point within the track linked list.
* The best point is the begging of the corresponding net code section.
* The best point is currently the end of the corresponding net code section.
* (The BOARD::m_Track and BOARD::m_Zone lists are sorted by netcode.)
* @param aPcb The BOARD to search for the insertion point.
* @return TRACK* - the item found in the linked list (or NULL if no track)
* @return TRACK* - the insertion point in the linked list.
* this is the next item after the last item having my net code.
* therefore the track to insert must be inserted before the insertion point.
* if the best insertion point is the end of list, the returned value is NULL
*/
TRACK* GetBestInsertPoint( BOARD* aPcb );