From 5ca2143ba140466bb2efcce4e0bc53424d15a7fe Mon Sep 17 00:00:00 2001 From: rblazek Date: Fri, 24 Mar 2006 11:01:17 +0000 Subject: [PATCH] fixed setting error rutin git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5093 c8812cc2-4d05-0410-92ff-de0c093fc19c --- src/providers/grass/qgsgrass.cpp | 14 +++++++++++--- src/providers/grass/qgsgrass.h | 3 ++- src/providers/grass/qgsgrassprovider.cpp | 2 ++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/providers/grass/qgsgrass.cpp b/src/providers/grass/qgsgrass.cpp index 778cc6d930c5..c2dc689bc871 100644 --- a/src/providers/grass/qgsgrass.cpp +++ b/src/providers/grass/qgsgrass.cpp @@ -38,6 +38,13 @@ extern "C" { void QgsGrass::init( void ) { + // Warning!!! + // G_set_error_routine() once called from plugin + // is not valid in provider -> call it always + + // Set error function + G_set_error_routine ( &error_routine ); + if ( initialized ) return; QSettings settings("QuantumGIS", "qgis"); @@ -59,9 +66,6 @@ void QgsGrass::init( void ) // Init GRASS libraries (required) G_no_gisinit(); // Doesn't check write permissions for mapset compare to G_gisinit("libgrass++"); - // Set error function - G_set_error_routine ( &error_routine ); - // Set program name G_set_program_name ("QGIS"); @@ -258,6 +262,10 @@ QString QgsGrass::defaultGisdbase; QString QgsGrass::defaultLocation; QString QgsGrass::defaultMapset; +QString QgsGrass::mMapsetLock; +QString QgsGrass::mGisrc; +QString QgsGrass::mTmp; + int QgsGrass::error_routine ( char *msg, int fatal) { std::cerr << "error_routine (fatal = " << fatal << "): " << msg << std::endl; diff --git a/src/providers/grass/qgsgrass.h b/src/providers/grass/qgsgrass.h index 9ba3973fcf63..1797ceb72a96 100644 --- a/src/providers/grass/qgsgrass.h +++ b/src/providers/grass/qgsgrass.h @@ -161,12 +161,13 @@ class QgsGrass { static QString error_message; static int error_routine ( char *msg, int fatal); // static because pointer to this function is set later -}; + // Current mapset lock file path static QString mMapsetLock; // Current mapset GISRC file path static QString mGisrc; // Temporary directory where GISRC and sockets are stored static QString mTmp; +}; #endif // QGSGRASS_H diff --git a/src/providers/grass/qgsgrassprovider.cpp b/src/providers/grass/qgsgrassprovider.cpp index 8d017e6f4ba0..5f3fa6b06cec 100644 --- a/src/providers/grass/qgsgrassprovider.cpp +++ b/src/providers/grass/qgsgrassprovider.cpp @@ -62,6 +62,8 @@ QgsGrassProvider::QgsGrassProvider(QString const & uri) std::cerr << "QgsGrassProvider URI: " << uri.toLocal8Bit().data() << std::endl; #endif + QgsGrass::init(); + QTime time; time.start();