[QGIS Commit] r9378 - trunk/qgis/src/providers/grass

svn_qgis at osgeo.org svn_qgis at osgeo.org
Mon Sep 22 16:27:25 EDT 2008


Author: telwertowski
Date: 2008-09-22 16:27:25 -0400 (Mon, 22 Sep 2008)
New Revision: 9378

Modified:
   trunk/qgis/src/providers/grass/qgsgrassprovider.cpp
Log:
Do not reload GRASS vector layer while layer is being modified by an external process. Redraw using previously loaded data until files are rewritten in a consistent state. Fix for #1168.


Modified: trunk/qgis/src/providers/grass/qgsgrassprovider.cpp
===================================================================
--- trunk/qgis/src/providers/grass/qgsgrassprovider.cpp	2008-09-22 19:38:57 UTC (rev 9377)
+++ trunk/qgis/src/providers/grass/qgsgrassprovider.cpp	2008-09-22 20:27:25 UTC (rev 9378)
@@ -1087,13 +1087,24 @@
   // Reopen vector
   QgsGrass::resetError(); // to "catch" error after Vect_open_old()
   Vect_set_open_level( 2 );
-  Vect_open_old( map->map, map->mapName.toAscii().data(), map->mapset.toAscii().data() );
+  if ( setjmp( QgsGrass::fatalErrorEnv() ) == 0 )
+  {
+    Vect_open_old( map->map, map->mapName.toAscii().data(), map->mapset.toAscii().data() );
+  }
+  QgsGrass::clearErrorEnv();
 
   if ( QgsGrass::getError() == QgsGrass::FATAL )
   {
     QgsDebugMsg( QString( "Cannot reopen GRASS vector: %1" ).arg( QgsGrass::getErrorMessage() ) );
 
-    // TODO if reopen fails, mLayers should be also updated
+    // if reopen fails, mLayers should be also updated
+    for ( unsigned int i = 0; i <  mLayers.size(); i++ )
+    {
+      if ( mLayers[i].mapId == mapId )
+      {
+        closeLayer( i );
+      }
+    }
     return;
   }
 
@@ -1149,6 +1160,13 @@
 
   if ( map->lastModified < di.lastModified() )
   {
+    // If the cidx file has been deleted, the map is currently being modified
+    // by an external tool. Do not update until the cidx file has been recreated.
+    if ( !QFileInfo( dp, "cidx" ).exists() )
+    {
+      QgsDebugMsg( QString( "**** The map %1 is being modified and is unavailable ****" ).arg( mapId ) );
+      return false;
+    }
     QgsDebugMsg( QString( "**** The map %1 was modified ****" ).arg( mapId ) );
 
     return true;



More information about the QGIS-commit mailing list