[QGIS Commit] r13157 - in trunk/qgis/src: plugins/grass providers/grass

svn_qgis at osgeo.org svn_qgis at osgeo.org
Thu Mar 25 05:00:54 EDT 2010


Author: rblazek
Date: 2010-03-25 05:00:53 -0400 (Thu, 25 Mar 2010)
New Revision: 13157

Modified:
   trunk/qgis/src/plugins/grass/qgsgrassselect.cpp
   trunk/qgis/src/providers/grass/qgsgrass.cpp
   trunk/qgis/src/providers/grass/qgsgrass.h
   trunk/qgis/src/providers/grass/qgsgrassrasterprovider.cpp
Log:
QgsGrass::Exception reverted to std::runtime_error because with QgsException could not be caught

Modified: trunk/qgis/src/plugins/grass/qgsgrassselect.cpp
===================================================================
--- trunk/qgis/src/plugins/grass/qgsgrassselect.cpp	2010-03-25 07:22:36 UTC (rev 13156)
+++ trunk/qgis/src/plugins/grass/qgsgrassselect.cpp	2010-03-25 09:00:53 UTC (rev 13157)
@@ -141,21 +141,15 @@
 
     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 )

Modified: trunk/qgis/src/providers/grass/qgsgrass.cpp
===================================================================
--- trunk/qgis/src/providers/grass/qgsgrass.cpp	2010-03-25 07:22:36 UTC (rev 13156)
+++ trunk/qgis/src/providers/grass/qgsgrass.cpp	2010-03-25 09:00:53 UTC (rev 13157)
@@ -1128,7 +1128,7 @@
     crs.createFromWkt( wkt );
 
   }
-  catch ( QgsException &e )
+  catch ( QgsGrass::Exception &e )
   {
     QMessageBox::warning( 0, QObject::tr( "Warning" ),
                           QObject::tr( "Cannot get projection " ) + "\n" + e.what() );
@@ -1151,7 +1151,7 @@
     }
     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() );
@@ -1174,7 +1174,7 @@
       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() );

Modified: trunk/qgis/src/providers/grass/qgsgrass.h
===================================================================
--- trunk/qgis/src/providers/grass/qgsgrass.h	2010-03-25 07:22:36 UTC (rev 13156)
+++ trunk/qgis/src/providers/grass/qgsgrass.h	2010-03-25 09:00:53 UTC (rev 13157)
@@ -23,6 +23,7 @@
 #include <grass/form.h>
 }
 
+#include <stdexcept>
 #include "qgsexception.h"
 #include <QString>
 #include <QMap>
@@ -35,10 +36,20 @@
 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.

Modified: trunk/qgis/src/providers/grass/qgsgrassrasterprovider.cpp
===================================================================
--- trunk/qgis/src/providers/grass/qgsgrassrasterprovider.cpp	2010-03-25 07:22:36 UTC (rev 13156)
+++ trunk/qgis/src/providers/grass/qgsgrassrasterprovider.cpp	2010-03-25 09:00:53 UTC (rev 13157)
@@ -104,8 +104,7 @@
   {
     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() );



More information about the QGIS-commit mailing list