Skip to content

Commit

Permalink
Added donor detail
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@11433 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
pcav committed Aug 19, 2009
1 parent 49ff12d commit 666c2a8
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 164 deletions.
2 changes: 1 addition & 1 deletion DONORS
Expand Up @@ -32,7 +32,7 @@ Ivan Marchesini|http://www.gfosservices.it/
James Crone
Jaroslaw Kowalczyk
Jason Jorgenson
John C. Tull
John C. Tull|http://www.wildnevada.org
John Dean
Kanton Solothurn SOGIS
Kevin Shook
Expand Down
9 changes: 4 additions & 5 deletions src/plugins/grass/qgsgrassmodel.cpp
Expand Up @@ -37,7 +37,7 @@ class QgsGrassModelItem
{
public:
QgsGrassModelItem( QgsGrassModelItem *parent, int row, QString name,
QString path, int type );
QString path, int type );
QgsGrassModelItem();
~QgsGrassModelItem();

Expand Down Expand Up @@ -81,7 +81,7 @@ QgsGrassModelItem::QgsGrassModelItem()

QgsGrassModelItem::~QgsGrassModelItem()
{
for ( int i = 0; i < mChildren.size();i++ )
for ( int i = 0; i < mChildren.size(); i++ )
{
delete mChildren[i];
}
Expand Down Expand Up @@ -606,13 +606,13 @@ void QgsGrassModel::addItems( QgsGrassModelItem *item, QStringList list, int typ

// Add new items

for ( int i = 0; i < list.size();i++ )
for ( int i = 0; i < list.size(); i++ )
{
QString name = list.at( i );
// QgsDebugMsg(QString("? add %1").arg(name));

int insertAt = item->mChildren.size();
for ( int i = 0; i < item->mChildren.size();i++ )
for ( int i = 0; i < item->mChildren.size(); i++ )
{
if ( item->mChildren[i]->name() == name )
{
Expand Down Expand Up @@ -897,7 +897,6 @@ QVariant QgsGrassModel::data( const QModelIndex &index, int role ) const
default:
return mIconDirectory;
}
return mIconDirectory;
}
return item->data( role );
}
Expand Down
13 changes: 8 additions & 5 deletions src/plugins/grass/qgsgrassnewmapset.cpp
Expand Up @@ -1268,17 +1268,20 @@ void QgsGrassNewMapset::createMapset()

int ret = 0;

QgsGrass::resetError();
if ( setjmp( QgsGrass::fatalErrorEnv() ) == 0 )
try
{
ret = G_make_location( location.toAscii().data(), &mCellHead, mProjInfo, mProjUnits, stdout );
}
QgsGrass::clearErrorEnv();
catch ( QgsGrass::Exception &e )
{
ret = -1;
Q_UNUSED( e );
}

if ( QgsGrass::getError() == QgsGrass::FATAL || ret != 0 )
if ( ret != 0 )
{
QMessageBox::warning( this, tr( "Create location" ),
tr( "Cannot create new location: %1" ).arg( QgsGrass::getErrorMessage() ) );
tr( "Cannot create new location: %1" ).arg( QgsGrass::errorMessage() ) );
return;
}

Expand Down
46 changes: 24 additions & 22 deletions src/plugins/grass/qgsgrassplugin.cpp
Expand Up @@ -301,14 +301,13 @@ void QgsGrassPlugin::addVector()
QgsGrass::setLocation( sel->gisdbase, sel->location );

/* Open vector */
QgsGrass::resetError();
Vect_set_open_level( 2 );
struct Map_info map;
int level = Vect_open_old_head( &map, sel->map.toAscii().data(),
sel->mapset.toAscii().data() );

if ( QgsGrass::getError() != QgsGrass::FATAL )
try
{
Vect_set_open_level( 2 );
struct Map_info map;
int level = Vect_open_old_head( &map, sel->map.toAscii().data(),
sel->mapset.toAscii().data() );

if ( level >= 2 )
{
// Count layers
Expand Down Expand Up @@ -336,9 +335,9 @@ void QgsGrassPlugin::addVector()

Vect_close( &map );
}
else
catch ( QgsGrass::Exception &e )
{
QMessageBox::warning( 0, tr( "Warning" ), tr( "Cannot open GRASS vector:\n %1" ).arg( QgsGrass::getErrorMessage() ) );
QMessageBox::warning( 0, tr( "Warning" ), tr( "Cannot open GRASS vector:\n %1" ).arg( e.what() ) );
}

qGisInterface->addVectorLayer( uri, name, "grass" );
Expand Down Expand Up @@ -486,25 +485,28 @@ void QgsGrassPlugin::newVector()
QgsGrass::getDefaultLocation(),
QgsGrass::getDefaultMapset() );

QgsGrass::resetError();
struct Map_info Map;
Vect_open_new( &Map, name.toAscii().data(), 0 );

if ( QgsGrass::getError() == QgsGrass::FATAL )
try
{
QMessageBox::warning( 0, tr( "Warning" ),
tr( "Cannot create new vector: %1" ).arg( QgsGrass::getErrorMessage() ) );
return;
}
struct Map_info Map;
Vect_open_new( &Map, name.toAscii().data(), 0 );

#if defined(GRASS_VERSION_MAJOR) && defined(GRASS_VERSION_MINOR) && \
( ( GRASS_VERSION_MAJOR == 6 && GRASS_VERSION_MINOR >= 4 ) || GRASS_VERSION_MAJOR > 6 )
Vect_build( &Map );
Vect_build( &Map );
#else
Vect_build( &Map, stderr );
Vect_build( &Map, stderr );
#endif
Vect_set_release_support( &Map );
Vect_close( &Map );
Vect_set_release_support( &Map );
Vect_close( &Map );
}
catch ( QgsGrass::Exception &e )
{
QMessageBox::warning( 0, tr( "Warning" ),
tr( "Cannot create new vector: %1" ).arg( e.what() ) );
return;
}



// Open in GRASS vector provider

Expand Down
9 changes: 4 additions & 5 deletions src/plugins/grass/qgsgrassselect.cpp
Expand Up @@ -410,15 +410,14 @@ QStringList QgsGrassSelect::vectorLayers( QString gisdbase,
// Call to setjmp() returns 0 first time. In case of fatal error,
// our error routine uses longjmp() to come back to this context,
// this time setjmp() will return non-zero value and we can continue...
if ( setjmp( QgsGrass::fatalErrorEnv() ) == 0 )

try
{
level = Vect_open_old_head( &map, ( char * ) mapName.toAscii().data(), ( char * ) mapset.toAscii().data() );
}
QgsGrass::clearErrorEnv();

if ( QgsGrass::getError() == QgsGrass::FATAL )
catch ( QgsGrass::Exception &e )
{
QgsDebugMsg( QString( "Cannot open GRASS vector: %1" ).arg( QgsGrass::getErrorMessage() ) );
QgsDebugMsg( QString( "Cannot open GRASS vector: %1" ).arg( e.what() ) );
return list;
}

Expand Down
42 changes: 9 additions & 33 deletions src/providers/grass/qgsgrass.cpp
Expand Up @@ -54,7 +54,8 @@ void GRASS_EXPORT QgsGrass::init( void )
// Set error function
G_set_error_routine( &error_routine );

if ( initialized ) return;
if ( initialized )
return;

QSettings settings;

Expand Down Expand Up @@ -355,7 +356,7 @@ int QgsGrass::initialized = 0;

bool QgsGrass::active = 0;

QgsGrass::GERROR QgsGrass::error = QgsGrass::OK;
QgsGrass::GERROR QgsGrass::lastError = QgsGrass::OK;

QString QgsGrass::error_message;

Expand All @@ -367,9 +368,6 @@ QString QgsGrass::mMapsetLock;
QString QgsGrass::mGisrc;
QString QgsGrass::mTmp;

jmp_buf QgsGrass::mFatalErrorEnv;
bool QgsGrass::mFatalErrorEnvActive = false;

int QgsGrass::error_routine( char *msg, int fatal )
{
return error_routine(( const char* ) msg, fatal );
Expand All @@ -383,52 +381,30 @@ int QgsGrass::error_routine( const char *msg, int fatal )

if ( fatal )
{
error = FATAL;
// we have to do a long jump here, otherwise GRASS >= 6.3 will kill our process
if ( mFatalErrorEnvActive )
longjmp( mFatalErrorEnv, 1 );
else
{
QMessageBox::warning( 0, QObject::tr( "Uncatched fatal GRASS error" ), msg );
abort();
}
throw QgsGrass::Exception( msg );
}
else
error = WARNING;
lastError = WARNING;

return 1;
}

void GRASS_EXPORT QgsGrass::resetError( void )
{
error = OK;
lastError = OK;
}

int GRASS_EXPORT QgsGrass::getError( void )
int GRASS_EXPORT QgsGrass::error( void )
{
return error;
return lastError;
}

QString GRASS_EXPORT QgsGrass::getErrorMessage( void )
QString GRASS_EXPORT QgsGrass::errorMessage( void )
{
return error_message;
}

jmp_buf GRASS_EXPORT &QgsGrass::fatalErrorEnv()
{
if ( mFatalErrorEnvActive )
QgsDebugMsg( "fatal error environment already active." );
mFatalErrorEnvActive = true;
return mFatalErrorEnv;
}

void GRASS_EXPORT QgsGrass::clearErrorEnv()
{
if ( !mFatalErrorEnvActive )
QgsDebugMsg( "fatal error environment already deactive." );
mFatalErrorEnvActive = false;
}

QString GRASS_EXPORT QgsGrass::openMapset( QString gisdbase, QString location, QString mapset )
{
QgsDebugMsg( QString( "gisdbase = %1" ).arg( gisdbase.toLocal8Bit().constData() ) );
Expand Down
29 changes: 13 additions & 16 deletions src/providers/grass/qgsgrass.h
Expand Up @@ -24,15 +24,21 @@ extern "C"
}

#include <QString>
#include <setjmp.h>

/*!
Methods for C library initialization and error handling.
*/
class QgsGrass
{

public:
class Exception
{
QString mMsg;
public:
Exception( const char *msg ) : mMsg( msg ) {}
QString what() const { return mMsg; }
};

//! Get info about the mode
/*! QgsGrass may be running in active or passive mode.
* Active mode means that GISRC is set up and GISRC file is available,
Expand Down Expand Up @@ -64,10 +70,9 @@ class QgsGrass
*/
static GRASS_EXPORT void setMapset( QString gisdbase, QString location, QString mapset );

//! Error codes returned by GetError()
//! Error codes returned by error()
enum GERROR { OK, /*!< OK. No error. */
WARNING, /*!< Warning, non fatal error. Should be printed by application. */
FATAL /*!< Fatal error. Function faild. */
WARNING /*!< Warning, non fatal error. Should be printed by application. */
};

//! Map type
Expand All @@ -77,10 +82,10 @@ class QgsGrass
static GRASS_EXPORT void resetError( void ); // reset error status

//! Check if any error occured in lately called functions. Returns value from ERROR.
static GRASS_EXPORT int getError( void );
static GRASS_EXPORT int error( void );

//! Get last error message
static GRASS_EXPORT QString getErrorMessage( void );
static GRASS_EXPORT QString errorMessage( void );

/** \brief Open existing GRASS mapset
* \return NULL string or error message
Expand Down Expand Up @@ -160,10 +165,6 @@ class QgsGrass
static GRASS_EXPORT int versionRelease();
static GRASS_EXPORT QString versionString();

static GRASS_EXPORT jmp_buf& fatalErrorEnv();
static GRASS_EXPORT void clearErrorEnv();


private:
static int initialized; // Set to 1 after initialization
static bool active; // is active mode
Expand All @@ -172,7 +173,7 @@ class QgsGrass
static QString defaultMapset;

/* last error in GRASS libraries */
static GERROR error; // static, because used in constructor
static GERROR lastError; // static, because used in constructor
static QString error_message;

// G_set_error_routine has two versions of the function's first argument it expects:
Expand All @@ -188,10 +189,6 @@ class QgsGrass
static QString mGisrc;
// Temporary directory where GISRC and sockets are stored
static QString mTmp;

// Context saved before a call to routine that can produce a fatal error
static jmp_buf mFatalErrorEnv;
static bool mFatalErrorEnvActive;
};

#endif // QGSGRASS_H

0 comments on commit 666c2a8

Please sign in to comment.