Bug 314539 - ClipPainter does not handle LineEnd position
Summary: ClipPainter does not handle LineEnd position
Status: RESOLVED FIXED
Alias: None
Product: marble
Classification: Applications
Component: general (show other bugs)
Version: 1.6 (KDE 4.11)
Platform: Other Linux
: NOR crash
Target Milestone: ---
Assignee: marble-bugs
URL: https://forum.kde.org/viewtopic.php?f...
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-06 18:16 UTC by Dennis Nienhüser
Modified: 2013-02-06 18:31 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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