Skip to content

Commit 89d2bac

Browse files
author
rblazek
committed
QgsGrass::Exception reverted to std::runtime_error because with QgsException could not be caught
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13157 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 2285b5a commit 89d2bac

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

src/plugins/grass/qgsgrassselect.cpp

-6
Original file line numberDiff line numberDiff line change
@@ -141,21 +141,15 @@ void QgsGrassSelect::setLocations()
141141

142142
QString ldpath = egisdbase->text() + "/" + d[i];
143143

144-
/* TODO: G_is_location() was added to GRASS 6.1 06-05-24,
145-
enable its use after some period (others do update) */
146-
#if 0
147144
if ( QgsGrass::versionMajor() > 6 || QgsGrass::versionMinor() > 0 )
148145
{
149146
if ( !G_is_location( ldpath.toLocal8Bit().constData() ) ) continue;
150147
}
151148
else
152149
{
153-
#endif
154150
QString chf = egisdbase->text() + "/" + d[i] + "/PERMANENT/DEFAULT_WIND";
155151
if ( !QFile::exists( chf ) ) continue;
156-
#if 0
157152
}
158-
#endif
159153

160154
// if type is MAPSET check also if at least one mapset owned by user exists
161155
if ( QgsGrassSelect::type == QgsGrassSelect::MAPSET )

src/providers/grass/qgsgrass.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1128,7 +1128,7 @@ QgsCoordinateReferenceSystem GRASS_EXPORT QgsGrass::crs( QString gisdbase, QStri
11281128
crs.createFromWkt( wkt );
11291129

11301130
}
1131-
catch ( QgsException &e )
1131+
catch ( QgsGrass::Exception &e )
11321132
{
11331133
QMessageBox::warning( 0, QObject::tr( "Warning" ),
11341134
QObject::tr( "Cannot get projection " ) + "\n" + e.what() );
@@ -1151,7 +1151,7 @@ QgsRectangle GRASS_EXPORT QgsGrass::extent( QString gisdbase, QString location,
11511151
}
11521152
return QgsRectangle( list[0].toDouble(), list[1].toDouble(), list[2].toDouble(), list[3].toDouble() ) ;
11531153
}
1154-
catch ( QgsException &e )
1154+
catch ( QgsGrass::Exception &e )
11551155
{
11561156
QMessageBox::warning( 0, QObject::tr( "Warning" ),
11571157
QObject::tr( "Cannot get raster extent" ) + "\n" + e.what() );
@@ -1174,7 +1174,7 @@ QMap<QString, QString> GRASS_EXPORT QgsGrass::query( QString gisdbase, QString l
11741174
result[list[0]] = list[1];
11751175
}
11761176
}
1177-
catch ( QgsException &e )
1177+
catch ( QgsGrass::Exception &e )
11781178
{
11791179
QMessageBox::warning( 0, QObject::tr( "Warning" ),
11801180
QObject::tr( "Cannot query raster " ) + "\n" + e.what() );

src/providers/grass/qgsgrass.h

+11
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ extern "C"
2323
#include <grass/form.h>
2424
}
2525

26+
#include <stdexcept>
2627
#include "qgsexception.h"
2728
#include <QString>
2829
#include <QMap>
@@ -35,10 +36,20 @@ class QgsRectangle;
3536
class QgsGrass
3637
{
3738
public:
39+
// This does not work (gcc/Linux), such exception cannot be caught
40+
// so I have enabled the old version, if you are able to fix it, please
41+
// check first if it realy works, i.e. can be caught!
42+
/*
3843
struct Exception : public QgsException
3944
{
4045
Exception( const QString &msg ) : QgsException( msg ) {}
4146
};
47+
*/
48+
struct Exception : public std::runtime_error
49+
{
50+
//Exception( const std::string &msg ) : std::runtime_error( msg ) {}
51+
Exception( const QString &msg ) : std::runtime_error( msg.toUtf8().constData() ) {}
52+
};
4253

4354
//! Get info about the mode
4455
/*! QgsGrass may be running in active or passive mode.

src/providers/grass/qgsgrassrasterprovider.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ QImage* QgsGrassRasterProvider::draw( QgsRectangle const & viewExtent, int pixe
104104
{
105105
data = QgsGrass::runModule ( mGisdbase, mLocation, cmd, arguments );
106106
}
107-
//catch ( QgsGrass::Exception &e ) // does not work
108-
catch ( QgsException &e )
107+
catch ( QgsGrass::Exception &e )
109108
{
110109
QMessageBox::warning( 0, QObject::tr( "Warning" ), QObject::tr( "Cannot draw raster" ) + "\n"
111110
+ e.what() );

0 commit comments

Comments
 (0)