Skip to content

Commit

Permalink
Catch some uncaught transform exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed May 29, 2018
1 parent ff7c70f commit c013c23
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
10 changes: 9 additions & 1 deletion src/app/vertextool/qgsvertexeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,15 @@ void QgsVertexEditor::zoomToVertex( int idx )
QgsPointXY newCenter( x, y );

QgsCoordinateTransform t( mLayer->crs(), mCanvas->mapSettings().destinationCrs(), QgsProject::instance() );
QgsPointXY tCenter = t.transform( newCenter );
QgsPointXY tCenter;
try
{
tCenter = t.transform( newCenter );
}
catch ( QgsCsException & )
{
return;
}

QPolygonF ext = mCanvas->mapSettings().visiblePolygon();
//close polygon
Expand Down
18 changes: 16 additions & 2 deletions src/core/qgsvectorlayerlabelprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,14 @@ QgsGeometry QgsVectorLayerLabelProvider::getPointObstacleGeometry( QgsFeature &f
//transform point to pixels
if ( context.coordinateTransform().isValid() )
{
context.coordinateTransform().transformInPlace( x, y, z );
try
{
context.coordinateTransform().transformInPlace( x, y, z );
}
catch ( QgsCsException & )
{
return QgsGeometry();
}
}
context.mapToPixel().transformInPlace( x, y );

Expand Down Expand Up @@ -318,7 +325,14 @@ QgsGeometry QgsVectorLayerLabelProvider::getPointObstacleGeometry( QgsFeature &f
}
if ( context.coordinateTransform().isValid() )
{
boundLineString->transform( context.coordinateTransform(), QgsCoordinateTransform::ReverseTransform );
try
{
boundLineString->transform( context.coordinateTransform(), QgsCoordinateTransform::ReverseTransform );
}
catch ( QgsCsException & )
{
return QgsGeometry();
}
}
boundLineString->close();

Expand Down
9 changes: 8 additions & 1 deletion src/gui/qgsrubberband.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,14 @@ void QgsRubberBand::addGeometry( const QgsGeometry &geometry, QgsVectorLayer *la
if ( layer )
{
QgsCoordinateTransform ct = mMapCanvas->mapSettings().layerTransform( layer );
geom.transform( ct );
try
{
geom.transform( ct );
}
catch ( QgsCsException & )
{
return;
}
}

addGeometry( geom );
Expand Down

0 comments on commit c013c23

Please sign in to comment.