Skip to content

Commit c1b683b

Browse files
authoredNov 12, 2017
Merge pull request #5595 from alexbruy/fix-north-arrow
[north arrow] prevent crash if project CRS is not defined
2 parents 66518eb + 19b1b79 commit c1b683b

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed
 

‎src/app/qgsdecorationnortharrow.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,15 @@ void QgsDecorationNorthArrow::render( const QgsMapSettings &mapSettings, QgsRend
123123
// called when the projection or map extent changes
124124
if ( mAutomatic )
125125
{
126-
mRotationInt = QgsBearingUtils:: bearingTrueNorth( mapSettings.destinationCrs(), context.extent().center() );
126+
try
127+
{
128+
mRotationInt = QgsBearingUtils:: bearingTrueNorth( mapSettings.destinationCrs(), context.extent().center() );
129+
}
130+
catch ( QgsException &e )
131+
{
132+
mRotationInt = 0.0;
133+
//QgsDebugMsg( "Can not get direction to true north. Probably project CRS is not defined." );
134+
}
127135
mRotationInt += mapSettings.rotation();
128136
}
129137

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

0 commit comments

Comments
 (0)
Please sign in to comment.