Skip to content

Commit e0bdd26

Browse files
rouaultnyalldawson
authored andcommitted
[OGR provider] When creating a new layer with createEmptyLayer(), make sure the opened datasets do not get reused
1 parent 0a092cc commit e0bdd26

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/providers/ogr/qgsogrprovider.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,8 @@ QgsVectorLayerExporter::ExportError QgsOgrProvider::createEmptyLayer( const QStr
343343
}
344344
}
345345
346+
QgsOgrProviderUtils::invalidateCachedLastModifiedDate( uri );
347+
346348
return QgsVectorLayerExporter::NoError;
347349
}
348350
@@ -4312,6 +4314,22 @@ static QDateTime getLastModified( const QString &dsName )
43124314
return QFileInfo( dsName ).lastModified();
43134315
}
43144316

4317+
// In case we do very fast structural changes within the same second,
4318+
// the last modified date might not change enough, so artificially
4319+
// decrement the cache modified date, so that the file appears newer to it
4320+
void QgsOgrProviderUtils::invalidateCachedLastModifiedDate( const QString &dsName )
4321+
{
4322+
QMutexLocker locker( &globalMutex );
4323+
4324+
auto iter = mapDSNameToLastModifiedDate.find( dsName );
4325+
if ( iter != mapDSNameToLastModifiedDate.end() )
4326+
{
4327+
QgsDebugMsg( QString( "invalidating last modified date for %1" ).arg( dsName ) );
4328+
iter.value() = iter.value().addSecs( -10 );
4329+
}
4330+
}
4331+
4332+
43154333
QString QgsOgrProviderUtils::expandAuthConfig( const QString &dsName )
43164334
{
43174335
QString uri( dsName );

src/providers/ogr/qgsogrprovider.h

+3
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,9 @@ class QgsOgrProviderUtils
418418

419419
//! Return the string to provide to QgsOgrConnPool::instance() methods
420420
static QString connectionPoolId( const QString &dataSourceURI );
421+
422+
//! Invalidate the cached last modified date of a dataset
423+
static void invalidateCachedLastModifiedDate( const QString &dsName );
421424
};
422425

423426

0 commit comments

Comments
 (0)