Fix a DRC crash on some installs.

It looks like D_GLIBCXX_ASSERTIONS=ON activated on some Linux versions creates too zealous tests at run time.
This patch just calculate the same pointer value using a slightly different formula.

Fix also a hard-to-understand comment

Fixes: lp:1770414
https://bugs.launchpad.net/kicad/+bug/1770414
This commit is contained in:
jean-pierre charras 2018-05-16 09:20:04 +02:00
parent 584409b2ef
commit 904eb82368
2 changed files with 13 additions and 7 deletions

View File

@ -633,6 +633,9 @@ void DRC::testPad2Pad()
m_pcb->GetSortedPadListByXthenYCoord( sortedPads ); m_pcb->GetSortedPadListByXthenYCoord( sortedPads );
if( sortedPads.size() == 0 )
return;
// find the max size of the pads (used to stop the test) // find the max size of the pads (used to stop the test)
int max_size = 0; int max_size = 0;
@ -647,9 +650,10 @@ void DRC::testPad2Pad()
max_size = radius; max_size = radius;
} }
// Test the pads // Upper limit of pad list (limit not included)
D_PAD** listEnd = &sortedPads[ sortedPads.size() ]; D_PAD** listEnd = &sortedPads[0] + sortedPads.size();
// Test the pads
for( unsigned i = 0; i< sortedPads.size(); ++i ) for( unsigned i = 0; i< sortedPads.size(); ++i )
{ {
D_PAD* pad = sortedPads[i]; D_PAD* pad = sortedPads[i];

View File

@ -311,10 +311,12 @@ private:
* *
* The pad list must be sorted by x coordinate. * The pad list must be sorted by x coordinate.
* *
* @param aRefPad The pad to test * @param aRefPad is the pad to test
* @param aStart The start of the pad list to test against * @param aStart is the first pad of the list to test against aRefPad
* @param aEnd Marks the end of the list and is not included * @param aEnd is the end of the list and is not included
* @param x_limit is used to stop the test (when the any pad's X coord exceeds this) * @param x_limit is used to stop the test
* (i.e. when the current pad pos X in list exceeds this limit, because the list
* is sorted by X coordinate)
*/ */
bool doPadToPadsDrc( D_PAD* aRefPad, D_PAD** aStart, D_PAD** aEnd, int x_limit ); bool doPadToPadsDrc( D_PAD* aRefPad, D_PAD** aStart, D_PAD** aEnd, int x_limit );
@ -322,7 +324,7 @@ private:
* Test the current segment. * Test the current segment.
* *
* @param aRefSeg The segment to test * @param aRefSeg The segment to test
* @param aStart The head of a list of tracks to test against (usually BOARD::m_Track) * @param aStart the first item of track list to test against (usually BOARD::m_Track)
* @param doPads true if should do pads test * @param doPads true if should do pads test
* @return bool - true if no problems, else false and m_currentMarker is * @return bool - true if no problems, else false and m_currentMarker is
* filled in with the problem information. * filled in with the problem information.