Skip to content
Permalink
Browse files

Merge pull request #5595 from alexbruy/fix-north-arrow

[north arrow] prevent crash if project CRS is not defined
  • Loading branch information
nyalldawson committed Nov 12, 2017
2 parents 66518eb + 19b1b79 commit c1b683b51e8ceae1a9a8b13226b1b1ea9e40e665
Showing with 9 additions and 2 deletions.
  1. +9 −2 src/app/qgsdecorationnortharrow.cpp
@@ -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();
}

@@ -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.
You can’t perform that action at this time.