Skip to content

Commit

Permalink
Proper invalidation of OGR sources on sync to disc
Browse files Browse the repository at this point in the history
Fixes #39574 and #35144
  • Loading branch information
bjornharrtell authored and jef-n committed Nov 9, 2020
1 parent 383090f commit e5821d2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/core/providers/ogr/qgsogrprovider.cpp
Expand Up @@ -2544,11 +2544,10 @@ bool QgsOgrProvider::changeAttributeValues( const QgsChangedAttributesMap &attr_
if ( mTransaction )
mTransaction->dirtyLastSavePoint();

if ( mOgrLayer->SyncToDisk() != OGRERR_NONE )
if ( !syncToDisc() )
{
pushError( tr( "OGR error syncing to disk: %1" ).arg( CPLGetLastErrorMsg() ) );
}
QgsOgrConnPool::instance()->invalidateConnections( QgsOgrProviderUtils::connectionPoolId( dataSourceUri( true ), mShareSameDatasetAmongLayers ) );
return returnValue;
}

Expand Down Expand Up @@ -2655,11 +2654,10 @@ bool QgsOgrProvider::changeGeometryValues( const QgsGeometryMap &geometry_map )
if ( mTransaction )
mTransaction->dirtyLastSavePoint();

if ( mOgrLayer->SyncToDisk() != OGRERR_NONE )
if ( !syncToDisc() )
{
pushError( tr( "OGR error syncing to disk: %1" ).arg( CPLGetLastErrorMsg() ) );
}
QgsOgrConnPool::instance()->invalidateConnections( QgsOgrProviderUtils::connectionPoolId( dataSourceUri( true ), mShareSameDatasetAmongLayers ) );
return returnvalue;
}

Expand Down Expand Up @@ -4572,6 +4570,8 @@ QString QgsOgrProviderUtils::quotedValue( const QVariant &value )

bool QgsOgrProvider::syncToDisc()
{
QgsOgrConnPool::instance()->invalidateConnections( QgsOgrProviderUtils::connectionPoolId( dataSourceUri( true ), mShareSameDatasetAmongLayers ) );

//for shapefiles, remove spatial index files and create a new index
QgsOgrConnPool::instance()->unref( QgsOgrProviderUtils::connectionPoolId( dataSourceUri( true ), mShareSameDatasetAmongLayers ) );
bool shapeIndex = false;
Expand Down

0 comments on commit e5821d2

Please sign in to comment.