Skip to content

Commit

Permalink
fixed #2003, crash if topo is not available
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@12782 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rblazek committed Jan 16, 2010
1 parent e7e159f commit 9ef9836
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
16 changes: 15 additions & 1 deletion src/plugins/grass/qgsgrassplugin.cpp
Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions src/plugins/grass/qgsgrassselect.cpp
Expand Up @@ -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() );
Expand All @@ -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;
}

Expand Down

0 comments on commit 9ef9836

Please sign in to comment.