PNS_NODE: fix segfault when dragging a track/corner of a track forming a ring

This commit is contained in:
Tomasz Wlostowski 2015-07-22 13:51:12 +02:00 committed by Maciej Suminski
parent 8752f46f07
commit afb6571249
1 changed files with 9 additions and 7 deletions

View File

@ -748,18 +748,16 @@ void PNS_NODE::followLine( PNS_SEGMENT* aCurrent, bool aScanDirection, int& aPos
assert( jt );
aCorners[aPos] = jt->Pos();
aSegments[aPos] = aCurrent;
aPos += ( aScanDirection ? 1 : -1 );
if( count && guard == p )
if( count && guard == p)
{
aSegments[aPos] = NULL;
aGuardHit = true;
break;
}
aSegments[aPos] = aCurrent;
aPos += ( aScanDirection ? 1 : -1 );
if( !jt->IsLineCorner() || aPos < 0 || aPos == aLimit )
break;
@ -796,6 +794,7 @@ PNS_LINE* PNS_NODE::AssembleLine( PNS_SEGMENT* aSeg, int* aOriginSegmentIndex)
int n = 0;
PNS_SEGMENT* prev_seg = NULL;
bool originSet = false;
for( int i = i_start + 1; i < i_end; i++ )
{
@ -807,9 +806,12 @@ PNS_LINE* PNS_NODE::AssembleLine( PNS_SEGMENT* aSeg, int* aOriginSegmentIndex)
{
pl->LinkSegment( segs[i] );
if( segs[i] == aSeg && aOriginSegmentIndex )
// latter condition to avoid loops
if( segs[i] == aSeg && aOriginSegmentIndex && !originSet )
{
*aOriginSegmentIndex = n;
originSet = true;
}
n++;
}