Skip to content

Commit 1ae2097

Browse files
author
mhugent
committed
Catch crs transformation exceptions in gpsmarker
git-svn-id: http://svn.osgeo.org/qgis/trunk@14437 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent b440e1e commit 1ae2097

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/app/gps/qgsgpsmarker.cpp

+12-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525

2626
QgsGpsMarker::QgsGpsMarker( QgsMapCanvas* mapCanvas )
27-
: QgsMapCanvasItem( mapCanvas )
27+
: QgsMapCanvasItem( mapCanvas )
2828
{
2929
mSize = 16;
3030
mWgs84CRS.createFromEpsg( 4326 );
@@ -38,10 +38,17 @@ void QgsGpsMarker::setSize( int theSize )
3838
void QgsGpsMarker::setCenter( const QgsPoint& point )
3939
{
4040
//transform to map crs
41-
if ( mMapCanvas && mMapCanvas->mapRenderer() )
41+
if( mMapCanvas && mMapCanvas->mapRenderer() )
4242
{
4343
QgsCoordinateTransform t( mWgs84CRS, mMapCanvas->mapRenderer()->destinationSrs() );
44-
mCenter = t.transform( point );
44+
try
45+
{
46+
mCenter = t.transform( point );
47+
}
48+
catch( QgsCsException e ) //silently ignore transformation exceptions
49+
{
50+
return;
51+
}
4552
}
4653
else
4754
{
@@ -55,7 +62,7 @@ void QgsGpsMarker::setCenter( const QgsPoint& point )
5562
void QgsGpsMarker::paint( QPainter* p )
5663
{
5764
QSvgRenderer mySVG;
58-
if ( !mySVG.load( QString( ":/images/north_arrows/gpsarrow2.svg" ) ) )
65+
if( !mySVG.load( QString( ":/images/north_arrows/gpsarrow2.svg" ) ) )
5966
{
6067
qDebug( "GPS marker not found!" );
6168
return;
@@ -68,7 +75,7 @@ void QgsGpsMarker::paint( QPainter* p )
6875
QRectF QgsGpsMarker::boundingRect() const
6976
{
7077
float myHalfSize = mSize / 2.0;
71-
return QRectF( -myHalfSize, -myHalfSize, 2.0*myHalfSize, 2.0*myHalfSize );
78+
return QRectF( -myHalfSize, -myHalfSize, 2.0 * myHalfSize, 2.0 * myHalfSize );
7279
}
7380

7481
void QgsGpsMarker::updatePosition()

0 commit comments

Comments
 (0)