[QGIS Commit] r14437 - trunk/qgis/src/app/gps

svn_qgis at osgeo.org svn_qgis at osgeo.org
Wed Oct 27 12:17:36 EDT 2010


Author: mhugent
Date: 2010-10-27 09:17:36 -0700 (Wed, 27 Oct 2010)
New Revision: 14437

Modified:
   trunk/qgis/src/app/gps/qgsgpsmarker.cpp
Log:
Catch crs transformation exceptions in gpsmarker

Modified: trunk/qgis/src/app/gps/qgsgpsmarker.cpp
===================================================================
--- trunk/qgis/src/app/gps/qgsgpsmarker.cpp	2010-10-26 09:09:51 UTC (rev 14436)
+++ trunk/qgis/src/app/gps/qgsgpsmarker.cpp	2010-10-27 16:17:36 UTC (rev 14437)
@@ -24,7 +24,7 @@
 
 
 QgsGpsMarker::QgsGpsMarker( QgsMapCanvas* mapCanvas )
-    : QgsMapCanvasItem( mapCanvas )
+  : QgsMapCanvasItem( mapCanvas )
 {
   mSize = 16;
   mWgs84CRS.createFromEpsg( 4326 );
@@ -38,10 +38,17 @@
 void QgsGpsMarker::setCenter( const QgsPoint& point )
 {
   //transform to map crs
-  if ( mMapCanvas && mMapCanvas->mapRenderer() )
+  if( mMapCanvas && mMapCanvas->mapRenderer() )
   {
     QgsCoordinateTransform t( mWgs84CRS, mMapCanvas->mapRenderer()->destinationSrs() );
-    mCenter = t.transform( point );
+    try
+    {
+      mCenter = t.transform( point );
+    }
+    catch( QgsCsException e ) //silently ignore transformation exceptions
+    {
+      return;
+    }
   }
   else
   {
@@ -55,7 +62,7 @@
 void QgsGpsMarker::paint( QPainter* p )
 {
   QSvgRenderer mySVG;
-  if ( !mySVG.load( QString( ":/images/north_arrows/gpsarrow2.svg" ) ) )
+  if( !mySVG.load( QString( ":/images/north_arrows/gpsarrow2.svg" ) ) )
   {
     qDebug( "GPS marker not found!" );
     return;
@@ -68,7 +75,7 @@
 QRectF QgsGpsMarker::boundingRect() const
 {
   float myHalfSize = mSize / 2.0;
-  return QRectF( -myHalfSize, -myHalfSize, 2.0*myHalfSize, 2.0*myHalfSize );
+  return QRectF( -myHalfSize, -myHalfSize, 2.0 * myHalfSize, 2.0 * myHalfSize );
 }
 
 void QgsGpsMarker::updatePosition()



More information about the QGIS-commit mailing list