Skip to content
Permalink
Browse files

[OGR provider] When creating a new layer with createEmptyLayer(), mak…

…e sure the opened datasets do not get reused
  • Loading branch information
rouault authored and nyalldawson committed Nov 23, 2017
1 parent 0a092cc commit e0bdd26e58f453d8470de0b5ca38aad006ca5ca3
Showing with 21 additions and 0 deletions.
  1. +18 −0 src/providers/ogr/qgsogrprovider.cpp
  2. +3 −0 src/providers/ogr/qgsogrprovider.h
@@ -343,6 +343,8 @@ QgsVectorLayerExporter::ExportError QgsOgrProvider::createEmptyLayer( const QStr
}
}
QgsOgrProviderUtils::invalidateCachedLastModifiedDate( uri );
return QgsVectorLayerExporter::NoError;
}
@@ -4312,6 +4314,22 @@ static QDateTime getLastModified( const QString &dsName )
return QFileInfo( dsName ).lastModified();
}

// In case we do very fast structural changes within the same second,
// the last modified date might not change enough, so artificially
// decrement the cache modified date, so that the file appears newer to it
void QgsOgrProviderUtils::invalidateCachedLastModifiedDate( const QString &dsName )
{
QMutexLocker locker( &globalMutex );

auto iter = mapDSNameToLastModifiedDate.find( dsName );
if ( iter != mapDSNameToLastModifiedDate.end() )
{
QgsDebugMsg( QString( "invalidating last modified date for %1" ).arg( dsName ) );
iter.value() = iter.value().addSecs( -10 );
}
}


QString QgsOgrProviderUtils::expandAuthConfig( const QString &dsName )
{
QString uri( dsName );
@@ -418,6 +418,9 @@ class QgsOgrProviderUtils

//! Return the string to provide to QgsOgrConnPool::instance() methods
static QString connectionPoolId( const QString &dataSourceURI );

//! Invalidate the cached last modified date of a dataset
static void invalidateCachedLastModifiedDate( const QString &dsName );
};


0 comments on commit e0bdd26

Please sign in to comment.
You can’t perform that action at this time.