Skip to content

Commit

Permalink
QgsGrass::Exception reverted to std::runtime_error because with QgsEx…
Browse files Browse the repository at this point in the history
…ception could not be caught

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13157 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rblazek committed Mar 25, 2010
1 parent 2285b5a commit 89d2bac
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
6 changes: 0 additions & 6 deletions src/plugins/grass/qgsgrassselect.cpp
Expand Up @@ -141,21 +141,15 @@ void QgsGrassSelect::setLocations()

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

/* TODO: G_is_location() was added to GRASS 6.1 06-05-24,
enable its use after some period (others do update) */
#if 0
if ( QgsGrass::versionMajor() > 6 || QgsGrass::versionMinor() > 0 )
{
if ( !G_is_location( ldpath.toLocal8Bit().constData() ) ) continue;
}
else
{
#endif
QString chf = egisdbase->text() + "/" + d[i] + "/PERMANENT/DEFAULT_WIND";
if ( !QFile::exists( chf ) ) continue;
#if 0
}
#endif

// if type is MAPSET check also if at least one mapset owned by user exists
if ( QgsGrassSelect::type == QgsGrassSelect::MAPSET )
Expand Down
6 changes: 3 additions & 3 deletions src/providers/grass/qgsgrass.cpp
Expand Up @@ -1128,7 +1128,7 @@ QgsCoordinateReferenceSystem GRASS_EXPORT QgsGrass::crs( QString gisdbase, QStri
crs.createFromWkt( wkt );

}
catch ( QgsException &e )
catch ( QgsGrass::Exception &e )
{
QMessageBox::warning( 0, QObject::tr( "Warning" ),
QObject::tr( "Cannot get projection " ) + "\n" + e.what() );
Expand All @@ -1151,7 +1151,7 @@ QgsRectangle GRASS_EXPORT QgsGrass::extent( QString gisdbase, QString location,
}
return QgsRectangle( list[0].toDouble(), list[1].toDouble(), list[2].toDouble(), list[3].toDouble() ) ;
}
catch ( QgsException &e )
catch ( QgsGrass::Exception &e )
{
QMessageBox::warning( 0, QObject::tr( "Warning" ),
QObject::tr( "Cannot get raster extent" ) + "\n" + e.what() );
Expand All @@ -1174,7 +1174,7 @@ QMap<QString, QString> GRASS_EXPORT QgsGrass::query( QString gisdbase, QString l
result[list[0]] = list[1];
}
}
catch ( QgsException &e )
catch ( QgsGrass::Exception &e )
{
QMessageBox::warning( 0, QObject::tr( "Warning" ),
QObject::tr( "Cannot query raster " ) + "\n" + e.what() );
Expand Down
11 changes: 11 additions & 0 deletions src/providers/grass/qgsgrass.h
Expand Up @@ -23,6 +23,7 @@ extern "C"
#include <grass/form.h>
}

#include <stdexcept>
#include "qgsexception.h"
#include <QString>
#include <QMap>
Expand All @@ -35,10 +36,20 @@ class QgsRectangle;
class QgsGrass
{
public:
// This does not work (gcc/Linux), such exception cannot be caught
// so I have enabled the old version, if you are able to fix it, please
// check first if it realy works, i.e. can be caught!
/*
struct Exception : public QgsException
{
Exception( const QString &msg ) : QgsException( msg ) {}
};
*/
struct Exception : public std::runtime_error
{
//Exception( const std::string &msg ) : std::runtime_error( msg ) {}
Exception( const QString &msg ) : std::runtime_error( msg.toUtf8().constData() ) {}
};

//! Get info about the mode
/*! QgsGrass may be running in active or passive mode.
Expand Down
3 changes: 1 addition & 2 deletions src/providers/grass/qgsgrassrasterprovider.cpp
Expand Up @@ -104,8 +104,7 @@ QImage* QgsGrassRasterProvider::draw( QgsRectangle const & viewExtent, int pixe
{
data = QgsGrass::runModule ( mGisdbase, mLocation, cmd, arguments );
}
//catch ( QgsGrass::Exception &e ) // does not work
catch ( QgsException &e )
catch ( QgsGrass::Exception &e )
{
QMessageBox::warning( 0, QObject::tr( "Warning" ), QObject::tr( "Cannot draw raster" ) + "\n"
+ e.what() );
Expand Down

0 comments on commit 89d2bac

Please sign in to comment.