mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-16 00:05:45 -04:00
Don't try to render zero-length segments for arrow symbol layer
This triggers a divide by zero, leading to an assert on Qt 6 builds. On Qt5 builds we try to render a polygon containing all nan values, which results in no rendered segment anyway, so there's no visual difference here.
This commit is contained in:
parent
d916c37ea5
commit
d416dc0179
@ -253,6 +253,8 @@ QPolygonF straightArrow( QPointF po, QPointF pd,
|
||||
QPolygonF polygon; // implicitly shared
|
||||
// vector length
|
||||
qreal length = euclidean_distance( po, pd );
|
||||
if ( qgsDoubleNear( length, 0 ) )
|
||||
return polygon;
|
||||
|
||||
// shift points if there is not enough room for the head(s)
|
||||
if ( ( headType == QgsArrowSymbolLayer::HeadSingle ) && ( length < headWidth ) )
|
||||
@ -747,8 +749,6 @@ void QgsArrowSymbolLayer::_resolveDataDefined( QgsSymbolRenderContext &context )
|
||||
|
||||
void QgsArrowSymbolLayer::renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context )
|
||||
{
|
||||
Q_UNUSED( points )
|
||||
|
||||
if ( !context.renderContext().painter() )
|
||||
{
|
||||
return;
|
||||
@ -792,7 +792,8 @@ void QgsArrowSymbolLayer::renderPolyline( const QPolygonF &points, QgsSymbolRend
|
||||
const QPointF pd( points.at( 1 ) );
|
||||
|
||||
const QPolygonF poly = straightArrow( po, pd, mScaledArrowStartWidth, mScaledArrowWidth, mScaledHeadLength, mScaledHeadThickness, mComputedHeadType, mComputedArrowType, mScaledOffset );
|
||||
mSymbol->renderPolygon( poly, /* rings */ nullptr, context.feature(), context.renderContext(), -1, useSelectedColor );
|
||||
if ( !poly.isEmpty() )
|
||||
mSymbol->renderPolygon( poly, /* rings */ nullptr, context.feature(), context.renderContext(), -1, useSelectedColor );
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -826,7 +827,8 @@ void QgsArrowSymbolLayer::renderPolyline( const QPolygonF &points, QgsSymbolRend
|
||||
const QPointF pd( points.at( pIdx + 1 ) );
|
||||
|
||||
const QPolygonF poly = straightArrow( po, pd, mScaledArrowStartWidth, mScaledArrowWidth, mScaledHeadLength, mScaledHeadThickness, mComputedHeadType, mComputedArrowType, mScaledOffset );
|
||||
mSymbol->renderPolygon( poly, /* rings */ nullptr, context.feature(), context.renderContext(), -1, useSelectedColor );
|
||||
if ( !poly.isEmpty() )
|
||||
mSymbol->renderPolygon( poly, /* rings */ nullptr, context.feature(), context.renderContext(), -1, useSelectedColor );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -845,7 +847,8 @@ void QgsArrowSymbolLayer::renderPolyline( const QPolygonF &points, QgsSymbolRend
|
||||
const QPointF pd( points.back() );
|
||||
|
||||
const QPolygonF poly = straightArrow( po, pd, mScaledArrowStartWidth, mScaledArrowWidth, mScaledHeadLength, mScaledHeadThickness, mComputedHeadType, mComputedArrowType, mScaledOffset );
|
||||
mSymbol->renderPolygon( poly, /* rings */ nullptr, context.feature(), context.renderContext(), -1, useSelectedColor );
|
||||
if ( !poly.isEmpty() )
|
||||
mSymbol->renderPolygon( poly, /* rings */ nullptr, context.feature(), context.renderContext(), -1, useSelectedColor );
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -866,7 +869,8 @@ void QgsArrowSymbolLayer::renderPolyline( const QPolygonF &points, QgsSymbolRend
|
||||
|
||||
const QPolygonF poly = straightArrow( po, pd, mScaledArrowStartWidth, mScaledArrowWidth, mScaledHeadLength, mScaledHeadThickness, mComputedHeadType, mComputedArrowType, mScaledOffset );
|
||||
|
||||
mSymbol->renderPolygon( poly, /* rings */ nullptr, context.feature(), context.renderContext(), -1, useSelectedColor );
|
||||
if ( !poly.isEmpty() )
|
||||
mSymbol->renderPolygon( poly, /* rings */ nullptr, context.feature(), context.renderContext(), -1, useSelectedColor );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user