Skip to content

Commit f463dfb

Browse files
author
telwertowski
committed
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.
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@9378 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent f1efcc0 commit f463dfb

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/providers/grass/qgsgrassprovider.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,13 +1087,24 @@ void QgsGrassProvider::updateMap( int mapId )
10871087
// Reopen vector
10881088
QgsGrass::resetError(); // to "catch" error after Vect_open_old()
10891089
Vect_set_open_level( 2 );
1090-
Vect_open_old( map->map, map->mapName.toAscii().data(), map->mapset.toAscii().data() );
1090+
if ( setjmp( QgsGrass::fatalErrorEnv() ) == 0 )
1091+
{
1092+
Vect_open_old( map->map, map->mapName.toAscii().data(), map->mapset.toAscii().data() );
1093+
}
1094+
QgsGrass::clearErrorEnv();
10911095

10921096
if ( QgsGrass::getError() == QgsGrass::FATAL )
10931097
{
10941098
QgsDebugMsg( QString( "Cannot reopen GRASS vector: %1" ).arg( QgsGrass::getErrorMessage() ) );
10951099

1096-
// TODO if reopen fails, mLayers should be also updated
1100+
// if reopen fails, mLayers should be also updated
1101+
for ( unsigned int i = 0; i < mLayers.size(); i++ )
1102+
{
1103+
if ( mLayers[i].mapId == mapId )
1104+
{
1105+
closeLayer( i );
1106+
}
1107+
}
10971108
return;
10981109
}
10991110

@@ -1149,6 +1160,13 @@ bool QgsGrassProvider::mapOutdated( int mapId )
11491160

11501161
if ( map->lastModified < di.lastModified() )
11511162
{
1163+
// If the cidx file has been deleted, the map is currently being modified
1164+
// by an external tool. Do not update until the cidx file has been recreated.
1165+
if ( !QFileInfo( dp, "cidx" ).exists() )
1166+
{
1167+
QgsDebugMsg( QString( "**** The map %1 is being modified and is unavailable ****" ).arg( mapId ) );
1168+
return false;
1169+
}
11521170
QgsDebugMsg( QString( "**** The map %1 was modified ****" ).arg( mapId ) );
11531171

11541172
return true;

0 commit comments

Comments
 (0)