Skip to content

Commit c0d51d1

Browse files
committed
[GRASS] catch fatal error in mapRegion()
1 parent a4f5d9a commit c0d51d1

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/providers/grass/qgsgrass.cpp

+11-4
Original file line numberDiff line numberDiff line change
@@ -1618,17 +1618,24 @@ bool QgsGrass::mapRegion( QgsGrassObject::Type type, QString gisdbase,
16181618
if ( type == QgsGrassObject::Raster )
16191619
{
16201620

1621+
QString error = tr( "Cannot read raster map region" ) + " (" + gisdbase + "/" + location + "/" + mapset + ")";
16211622
#if GRASS_VERSION_MAJOR < 7
16221623
if ( G_get_cellhd( map.toUtf8().data(),
16231624
mapset.toUtf8().data(), window ) < 0 )
16241625
{
1625-
QMessageBox::warning( 0, QObject::tr( "Warning" ),
1626-
QObject::tr( "Cannot read raster map region" ) );
1626+
warning( error );
16271627
return false;
16281628
}
16291629
#else
1630-
// TODO7: unfortunately Rast_get_cellhd does not return error code and calls G_fatal_error on error
1631-
Rast_get_cellhd( map.toUtf8().data(), mapset.toUtf8().data(), window );
1630+
G_TRY
1631+
{
1632+
Rast_get_cellhd( map.toUtf8().data(), mapset.toUtf8().data(), window );
1633+
}
1634+
G_CATCH( QgsGrass::Exception &e )
1635+
{
1636+
warning( error + " : " + e.what() );
1637+
return false;
1638+
}
16321639
#endif
16331640
}
16341641
else if ( type == QgsGrassObject::Vector )

0 commit comments

Comments
 (0)