Skip to content
Permalink
Browse files

fixed #2003, crash if topo is not available

git-svn-id: http://svn.osgeo.org/qgis/trunk@12782 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rblazek
rblazek committed Jan 16, 2010
1 parent 486cf59 commit 88fafe4199cdbadc12a019798121304b82c4e656
Showing with 25 additions and 11 deletions.
  1. +15 −1 src/plugins/grass/qgsgrassplugin.cpp
  2. +10 −10 src/plugins/grass/qgsgrassselect.cpp
@@ -303,11 +303,25 @@ void QgsGrassPlugin::addVector()
/* Open vector */
try
{
Vect_set_open_level( 2 );
//Vect_set_open_level( 2 );
struct Map_info map;
int level = Vect_open_old_head( &map, sel->map.toUtf8().data(),
sel->mapset.toUtf8().data() );

if ( level == 1 )
{
QgsDebugMsg( "Cannot open vector on level 2" );
QMessageBox::warning( 0, tr( "Warning" ), tr( "Cannot open vector ") + sel->map + tr(" in mapset ") + sel->mapset + tr (" on level 2 (topology not available, try to rebuild tobopoly using v.build module)." ) );
Vect_close( &map );
return;
}
else if ( level < 1 )
{
QgsDebugMsg( "Cannot open vector" );
QMessageBox::warning( 0, tr( "Warning" ), tr( "Cannot open vector ") + sel->map + tr(" in mapset ") + sel->mapset );
return;
}

if ( level >= 2 )
{
// Count layers
@@ -400,17 +400,10 @@ QStringList QgsGrassSelect::vectorLayers( QString gisdbase,

/* Open vector */
QgsGrass::resetError();
Vect_set_open_level( 2 );
//Vect_set_open_level( 2 );
struct Map_info map;
int level = -1;

// Mechanism to recover from fatal errors in GRASS
// Since fatal error routine in GRASS >= 6.3 terminates the process,
// we use setjmp() to set recovery place in case of a fatal error.
// 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...

try
{
level = Vect_open_old_head( &map, ( char * ) mapName.toUtf8().data(), ( char * ) mapset.toUtf8().data() );
@@ -422,10 +415,17 @@ QStringList QgsGrassSelect::vectorLayers( QString gisdbase,
return list;
}

if ( level < 2 )
if ( level == 1 )
{
QgsDebugMsg( "Cannot open vector on level 2" );
QMessageBox::warning( 0, tr( "Warning" ), tr( "Cannot open vector on level 2 (topology not available)." ) );
QMessageBox::warning( 0, tr( "Warning" ), tr( "Cannot open vector ") + mapName + tr(" in mapset ") + mapset + tr (" on level 2 (topology not available, try to rebuild tobopoly using v.build module)." ) );
Vect_close( &map );
return list;
}
else if ( level < 1 )
{
QgsDebugMsg( "Cannot open vector" );
QMessageBox::warning( 0, tr( "Warning" ), tr( "Cannot open vector ") + mapName + tr(" in mapset ") + mapset );
return list;
}

0 comments on commit 88fafe4

Please sign in to comment.
You can’t perform that action at this time.