[QGIS Commit] r12782 - trunk/qgis/src/plugins/grass

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sat Jan 16 13:27:06 EST 2010


Author: rblazek
Date: 2010-01-16 13:27:02 -0500 (Sat, 16 Jan 2010)
New Revision: 12782

Modified:
   trunk/qgis/src/plugins/grass/qgsgrassplugin.cpp
   trunk/qgis/src/plugins/grass/qgsgrassselect.cpp
Log:
fixed #2003, crash if topo is not available

Modified: trunk/qgis/src/plugins/grass/qgsgrassplugin.cpp
===================================================================
--- trunk/qgis/src/plugins/grass/qgsgrassplugin.cpp	2010-01-16 17:58:36 UTC (rev 12781)
+++ trunk/qgis/src/plugins/grass/qgsgrassplugin.cpp	2010-01-16 18:27:02 UTC (rev 12782)
@@ -303,11 +303,25 @@
     /* 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

Modified: trunk/qgis/src/plugins/grass/qgsgrassselect.cpp
===================================================================
--- trunk/qgis/src/plugins/grass/qgsgrassselect.cpp	2010-01-16 17:58:36 UTC (rev 12781)
+++ trunk/qgis/src/plugins/grass/qgsgrassselect.cpp	2010-01-16 18:27:02 UTC (rev 12782)
@@ -400,17 +400,10 @@
 
   /* 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,11 +415,18 @@
     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;
   }
 
   QgsDebugMsg( "GRASS vector successfully opened" );



More information about the QGIS-commit mailing list