@@ -24,21 +24,15 @@ extern "C"
24
24
}
25
25
26
26
#include < QString>
27
+ #include < setjmp.h>
27
28
28
29
/* !
29
30
Methods for C library initialization and error handling.
30
31
*/
31
32
class QgsGrass
32
33
{
33
- public:
34
- class Exception
35
- {
36
- QString mMsg ;
37
- public:
38
- Exception ( const char *msg ) : mMsg ( msg ) {}
39
- QString what () const { return mMsg ; }
40
- };
41
34
35
+ public:
42
36
// ! Get info about the mode
43
37
/* ! QgsGrass may be running in active or passive mode.
44
38
* Active mode means that GISRC is set up and GISRC file is available,
@@ -70,9 +64,10 @@ class QgsGrass
70
64
*/
71
65
static GRASS_EXPORT void setMapset ( QString gisdbase, QString location, QString mapset );
72
66
73
- // ! Error codes returned by error ()
67
+ // ! Error codes returned by GetError ()
74
68
enum GERROR { OK, /* !< OK. No error. */
75
- WARNING /* !< Warning, non fatal error. Should be printed by application. */
69
+ WARNING, /* !< Warning, non fatal error. Should be printed by application. */
70
+ FATAL /* !< Fatal error. Function faild. */
76
71
};
77
72
78
73
// ! Map type
@@ -82,10 +77,10 @@ class QgsGrass
82
77
static GRASS_EXPORT void resetError ( void ); // reset error status
83
78
84
79
// ! Check if any error occured in lately called functions. Returns value from ERROR.
85
- static GRASS_EXPORT int error ( void );
80
+ static GRASS_EXPORT int getError ( void );
86
81
87
82
// ! Get last error message
88
- static GRASS_EXPORT QString errorMessage ( void );
83
+ static GRASS_EXPORT QString getErrorMessage ( void );
89
84
90
85
/* * \brief Open existing GRASS mapset
91
86
* \return NULL string or error message
@@ -165,6 +160,10 @@ class QgsGrass
165
160
static GRASS_EXPORT int versionRelease ();
166
161
static GRASS_EXPORT QString versionString ();
167
162
163
+ static GRASS_EXPORT jmp_buf & fatalErrorEnv ();
164
+ static GRASS_EXPORT void clearErrorEnv ();
165
+
166
+
168
167
private:
169
168
static int initialized; // Set to 1 after initialization
170
169
static bool active; // is active mode
@@ -173,7 +172,7 @@ class QgsGrass
173
172
static QString defaultMapset;
174
173
175
174
/* last error in GRASS libraries */
176
- static GERROR lastError ; // static, because used in constructor
175
+ static GERROR error ; // static, because used in constructor
177
176
static QString error_message;
178
177
179
178
// G_set_error_routine has two versions of the function's first argument it expects:
@@ -189,6 +188,10 @@ class QgsGrass
189
188
static QString mGisrc ;
190
189
// Temporary directory where GISRC and sockets are stored
191
190
static QString mTmp ;
191
+
192
+ // Context saved before a call to routine that can produce a fatal error
193
+ static jmp_buf mFatalErrorEnv ;
194
+ static bool mFatalErrorEnvActive ;
192
195
};
193
196
194
197
#endif // QGSGRASS_H
0 commit comments