Skip to content

Commit

Permalink
Merge pull request #5595 from alexbruy/fix-north-arrow
Browse files Browse the repository at this point in the history
[north arrow] prevent crash if project CRS is not defined
  • Loading branch information
nyalldawson committed Nov 12, 2017
2 parents 66518eb + 19b1b79 commit c1b683b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/app/qgsdecorationnortharrow.cpp
Expand Up @@ -123,7 +123,15 @@ void QgsDecorationNorthArrow::render( const QgsMapSettings &mapSettings, QgsRend
// called when the projection or map extent changes
if ( mAutomatic )
{
mRotationInt = QgsBearingUtils:: bearingTrueNorth( mapSettings.destinationCrs(), context.extent().center() );
try
{
mRotationInt = QgsBearingUtils:: bearingTrueNorth( mapSettings.destinationCrs(), context.extent().center() );
}
catch ( QgsException &e )
{
mRotationInt = 0.0;
//QgsDebugMsg( "Can not get direction to true north. Probably project CRS is not defined." );
}
mRotationInt += mapSettings.rotation();
}

Expand Down Expand Up @@ -210,5 +218,4 @@ void QgsDecorationNorthArrow::render( const QgsMapSettings &mapSettings, QgsRend
context.painter()->drawText( 10, 20, tr( "North arrow pixmap not found" ) );
}
}

}

0 comments on commit c1b683b

Please sign in to comment.