Bug 314539

Summary: ClipPainter does not handle LineEnd position
Product: [Applications] marble Reporter: Dennis Nienhüser <nienhueser>
Component: generalAssignee: marble-bugs
Status: RESOLVED FIXED    
Severity: crash    
Priority: NOR    
Version: 1.6 (KDE 4.11)   
Target Milestone: ---   
Platform: Other   
OS: Linux   
URL: https://forum.kde.org/viewtopic.php?f=217&t=109874&p=258141#p258141
Latest Commit: Version Fixed In:

Description Dennis Nienhüser 2013-02-06 18:16:58 UTC
Quoting the forum thread:
"When drawing a polyline with a label at the end, out of bounds occurs in function ClipPainterPrivate::labelPosition (file ClipPainter.cpp)."

Proposed fix:
void ClipPainterPrivate::labelPosition( const QPolygonF & polygon, QVector<QPointF>& labelNodes, 
                                        LabelPositionFlags labelPositionFlags)
{
    int labelPosition = 0;

    <...>

    if ( polygon.size() > 1 && labelPositionFlags.testFlag( LineEnd ) ) {
        if ( pointAllowsLabel( polygon.at( polygon.size() - 1 ) ) ) {
            labelNodes << polygon.at( polygon.size() - 1 );
        }

///# Error occurs at first iteration
///-        // The Label at the start of the polyline:
///-        for ( int it = polygon.size() - 1; it > 1; --it ) {
///# Instead use this:
        // The Label at the end of the polyline: 
        for ( int it = polygon.size() - 2; it > 0; --it ) {
///# End of fix.
            currentAllowsLabel = pointAllowsLabel( polygon.at( it ) );

            if ( currentAllowsLabel ) {
                QPointF node = interpolateLabelPoint( polygon.at( it + 1 ), polygon.at( it ),
                                                    labelPositionFlags );
                if ( node != QPointF( -1.0, -1.0 ) ) {
                    labelNodes << node;
                }
                break;
            }
        }
    }
}
Comment 1 Dennis Nienhüser 2013-02-06 18:31:40 UTC
Fixed with http://commits.kde.org/marble/c07305063dbd73d4bb524c6a2eae61a994c49977