Commit f1498538 authored by Dennis Nienhüser's avatar Dennis Nienhüser
Browse files

Fix crash with Yours (number of turn points and segments can differ)

parent 73ab5606
...@@ -312,34 +312,35 @@ void RoutingLayerPrivate::renderRoute( GeoPainter *painter ) ...@@ -312,34 +312,35 @@ void RoutingLayerPrivate::renderRoute( GeoPainter *painter )
return; return;
} }
Q_ASSERT( m_routingModel->rowCount() == m_routingModel->route().size() ); if( m_routingModel->rowCount() == m_routingModel->route().size() ) {
m_instructionRegions.clear(); m_instructionRegions.clear();
for ( int i = 0; i < m_routingModel->rowCount(); ++i ) { for ( int i = 0; i < m_routingModel->rowCount(); ++i ) {
QModelIndex index = m_routingModel->index( i, 0 ); QModelIndex index = m_routingModel->index( i, 0 );
GeoDataCoordinates pos = index.data( MarblePlacemarkModel::CoordinateRole ).value<GeoDataCoordinates>(); GeoDataCoordinates pos = index.data( MarblePlacemarkModel::CoordinateRole ).value<GeoDataCoordinates>();
painter->setBrush( QBrush( m_marbleWidget->model()->routingManager()->routeColorAlternative() ) ); painter->setBrush( QBrush( m_marbleWidget->model()->routingManager()->routeColorAlternative() ) );
if ( m_selectionModel && m_selectionModel->selection().contains( index ) ) { if ( m_selectionModel && m_selectionModel->selection().contains( index ) ) {
const RouteSegment &segment = m_routingModel->route().at( i ); const RouteSegment &segment = m_routingModel->route().at( i );
const GeoDataLineString currentRoutePoints = segment.path(); const GeoDataLineString currentRoutePoints = segment.path();
QPen activeRouteSegmentPen( m_marbleWidget->model()->routingManager()->routeColorHighlighted() ); QPen activeRouteSegmentPen( m_marbleWidget->model()->routingManager()->routeColorHighlighted() );
activeRouteSegmentPen.setWidth( 6 ); activeRouteSegmentPen.setWidth( 6 );
if ( m_marbleWidget->model()->routingManager()->state() == RoutingManager::Downloading ) { if ( m_marbleWidget->model()->routingManager()->state() == RoutingManager::Downloading ) {
activeRouteSegmentPen.setStyle( Qt::DotLine ); activeRouteSegmentPen.setStyle( Qt::DotLine );
} }
painter->setPen( activeRouteSegmentPen ); painter->setPen( activeRouteSegmentPen );
painter->drawPolyline( currentRoutePoints ); painter->drawPolyline( currentRoutePoints );
painter->setPen( standardRoutePen ); painter->setPen( standardRoutePen );
painter->setBrush( QBrush( alphaAdjusted( Oxygen::hotOrange4, 200 ) ) ); painter->setBrush( QBrush( alphaAdjusted( Oxygen::hotOrange4, 200 ) ) );
} }
painter->drawEllipse( pos, 6, 6 ); painter->drawEllipse( pos, 6, 6 );
if ( m_isInteractive ) { if ( m_isInteractive ) {
QRegion region = painter->regionFromEllipse( pos, 12, 12 ); QRegion region = painter->regionFromEllipse( pos, 12, 12 );
m_instructionRegions.push_front( ModelRegion( index, region ) ); m_instructionRegions.push_front( ModelRegion( index, region ) );
}
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment