@@ -94,16 +94,16 @@ static bool IsLocalFile( const QString &path );
9494
9595static const QByteArray ORIG_OGC_FID = " orig_ogc_fid" ;
9696
97- QMutex QgsOgrProviderUtils::globalMutex ( QMutex::Recursive );
97+ QMutex QgsOgrProviderUtils::sGlobalMutex ( QMutex::Recursive );
9898
9999QMap< QgsOgrProviderUtils::DatasetIdentification,
100- QList<QgsOgrProviderUtils::DatasetWithLayers *> > QgsOgrProviderUtils::mapSharedDS ;
100+ QList<QgsOgrProviderUtils::DatasetWithLayers *> > QgsOgrProviderUtils::sMapSharedDS ;
101101
102- QMap< QString, int > QgsOgrProviderUtils::mapCountOpenedDS ;
102+ QMap< QString, int > QgsOgrProviderUtils::sMapCountOpenedDS ;
103103
104- QMap< GDALDatasetH, bool> QgsOgrProviderUtils::mapDSHandleToUpdateMode ;
104+ QMap< GDALDatasetH, bool> QgsOgrProviderUtils::sMapDSHandleToUpdateMode ;
105105
106- QMap< QString, QDateTime > QgsOgrProviderUtils::mapDSNameToLastModifiedDate ;
106+ QMap< QString, QDateTime > QgsOgrProviderUtils::sMapDSNameToLastModifiedDate ;
107107
108108bool QgsOgrProvider::convertField( QgsField &field, const QTextCodec &encoding )
109109{
@@ -3398,9 +3398,9 @@ GDALDatasetH QgsOgrProviderUtils::GDALOpenWrapper( const char *pszPath, bool bUp
33983398 GDALDriverH hDrv = GDALGetDatasetDriver ( hDS );
33993399 if ( bIsLocalGpkg && strcmp ( GDALGetDriverShortName ( hDrv ), " GPKG" ) == 0 )
34003400 {
3401- QMutexLocker locker ( &globalMutex );
3402- mapCountOpenedDS [ filePath ]++;
3403- mapDSHandleToUpdateMode [ hDS ] = bUpdate;
3401+ QMutexLocker locker ( &sGlobalMutex );
3402+ sMapCountOpenedDS [ filePath ]++;
3403+ sMapDSHandleToUpdateMode [ hDS ] = bUpdate;
34043404 }
34053405 if ( phDriver )
34063406 *phDriver = hDrv;
@@ -3460,15 +3460,15 @@ void QgsOgrProviderUtils::GDALCloseWrapper( GDALDatasetH hDS )
34603460 bool openedAsUpdate = false ;
34613461 bool tryReturnToWall = false ;
34623462 {
3463- QMutexLocker locker ( &globalMutex );
3464- mapCountOpenedDS [ datasetName ] --;
3465- if ( mapCountOpenedDS [ datasetName ] == 0 )
3463+ QMutexLocker locker ( &sGlobalMutex );
3464+ sMapCountOpenedDS [ datasetName ] --;
3465+ if ( sMapCountOpenedDS [ datasetName ] == 0 )
34663466 {
3467- mapCountOpenedDS .remove ( datasetName );
3468- openedAsUpdate = mapDSHandleToUpdateMode [hDS];
3467+ sMapCountOpenedDS .remove ( datasetName );
3468+ openedAsUpdate = sMapDSHandleToUpdateMode [hDS];
34693469 tryReturnToWall = true ;
34703470 }
3471- mapDSHandleToUpdateMode .remove ( hDS );
3471+ sMapDSHandleToUpdateMode .remove ( hDS );
34723472 }
34733473 if ( tryReturnToWall )
34743474 {
@@ -4121,15 +4121,15 @@ static GDALDatasetH OpenHelper( const QString &dsName,
41214121
41224122void QgsOgrProviderUtils::invalidateCachedDatasets ( const QString &dsName )
41234123{
4124- QMutexLocker locker ( &globalMutex );
4124+ QMutexLocker locker ( &sGlobalMutex );
41254125 while ( true )
41264126 {
41274127 bool erased = false ;
4128- for ( auto iter = mapSharedDS .begin (); iter != mapSharedDS .end (); ++iter )
4128+ for ( auto iter = sMapSharedDS .begin (); iter != sMapSharedDS .end (); ++iter )
41294129 {
41304130 if ( iter.key ().dsName == dsName )
41314131 {
4132- mapSharedDS .erase ( iter );
4132+ sMapSharedDS .erase ( iter );
41334133 erased = true ;
41344134 break ;
41354135 }
@@ -4143,8 +4143,8 @@ QgsOgrLayerUniquePtr QgsOgrProviderUtils::getLayer( const QString &dsName,
41434143 int layerIndex,
41444144 QString &errCause )
41454145{
4146- QMutexLocker locker ( &globalMutex );
4147- for ( auto iter = mapSharedDS .begin (); iter != mapSharedDS .end (); ++iter )
4146+ QMutexLocker locker ( &sGlobalMutex );
4147+ for ( auto iter = sMapSharedDS .begin (); iter != sMapSharedDS .end (); ++iter )
41484148 {
41494149 if ( iter.key ().dsName == dsName )
41504150 {
@@ -4184,7 +4184,7 @@ QgsOgrLayerUniquePtr QgsOgrProviderUtils::getLayer( const QString &dsName,
41844184 int layerIndex,
41854185 QString &errCause )
41864186{
4187- QMutexLocker locker ( &globalMutex );
4187+ QMutexLocker locker ( &sGlobalMutex );
41884188
41894189 // The idea is that we want to minimize the number of GDALDatasetH
41904190 // handles openeded. But we have constraints. We do not want that 2
@@ -4197,8 +4197,8 @@ QgsOgrLayerUniquePtr QgsOgrProviderUtils::getLayer( const QString &dsName,
41974197 ident.options = options;
41984198 // Find if there's a list of DatasetWithLayers* that match our
41994199 // (dsName, updateMode, options) criteria
4200- auto iter = mapSharedDS .find ( ident );
4201- if ( iter != mapSharedDS .end () )
4200+ auto iter = sMapSharedDS .find ( ident );
4201+ if ( iter != sMapSharedDS .end () )
42024202 {
42034203 // Browse through this list, to look for a DatasetWithLayers*
42044204 // instance that don't use yet our layer of interest
@@ -4254,7 +4254,7 @@ QgsOgrLayerUniquePtr QgsOgrProviderUtils::getLayer( const QString &dsName,
42544254
42554255 QList<DatasetWithLayers *> datasetList;
42564256 datasetList.push_back ( ds );
4257- mapSharedDS [ident] = datasetList;
4257+ sMapSharedDS [ident] = datasetList;
42584258
42594259 return layer;
42604260}
@@ -4263,9 +4263,9 @@ QgsOgrLayerUniquePtr QgsOgrProviderUtils::getLayer( const QString &dsName,
42634263 const QString &layerName,
42644264 QString &errCause )
42654265{
4266- QMutexLocker locker ( &globalMutex );
4266+ QMutexLocker locker ( &sGlobalMutex );
42674267
4268- for ( auto iter = mapSharedDS .begin (); iter != mapSharedDS .end (); ++iter )
4268+ for ( auto iter = sMapSharedDS .begin (); iter != sMapSharedDS .end (); ++iter )
42694269 {
42704270 if ( iter.key ().dsName == dsName )
42714271 {
@@ -4319,10 +4319,10 @@ static QDateTime getLastModified( const QString &dsName )
43194319// decrement the cache modified date, so that the file appears newer to it
43204320void QgsOgrProviderUtils::invalidateCachedLastModifiedDate ( const QString &dsName )
43214321{
4322- QMutexLocker locker ( &globalMutex );
4322+ QMutexLocker locker ( &sGlobalMutex );
43234323
4324- auto iter = mapDSNameToLastModifiedDate .find ( dsName );
4325- if ( iter != mapDSNameToLastModifiedDate .end () )
4324+ auto iter = sMapDSNameToLastModifiedDate .find ( dsName );
4325+ if ( iter != sMapDSNameToLastModifiedDate .end () )
43264326 {
43274327 QgsDebugMsg ( QString ( " invalidating last modified date for %1" ).arg ( dsName ) );
43284328 iter.value () = iter.value ().addSecs ( -10 );
@@ -4353,8 +4353,8 @@ QString QgsOgrProviderUtils::expandAuthConfig( const QString &dsName )
43534353// Must be called under the globalMutex
43544354bool QgsOgrProviderUtils::canUseOpenedDatasets ( const QString &dsName )
43554355{
4356- auto iter = mapDSNameToLastModifiedDate .find ( dsName );
4357- if ( iter == mapDSNameToLastModifiedDate .end () )
4356+ auto iter = sMapDSNameToLastModifiedDate .find ( dsName );
4357+ if ( iter == sMapDSNameToLastModifiedDate .end () )
43584358 return true ;
43594359 return getLastModified ( dsName ) <= iter.value ();
43604360}
@@ -4366,7 +4366,7 @@ QgsOgrLayerUniquePtr QgsOgrProviderUtils::getLayer( const QString &dsName,
43664366 const QString &layerName,
43674367 QString &errCause )
43684368{
4369- QMutexLocker locker ( &globalMutex );
4369+ QMutexLocker locker ( &sGlobalMutex );
43704370
43714371 // The idea is that we want to minimize the number of GDALDatasetH
43724372 // handles openeded. But we have constraints. We do not want that 2
@@ -4379,18 +4379,18 @@ QgsOgrLayerUniquePtr QgsOgrProviderUtils::getLayer( const QString &dsName,
43794379 ident.options = options;
43804380 // Find if there's a list of DatasetWithLayers* that match our
43814381 // (dsName, updateMode, options) criteria
4382- auto iter = mapSharedDS .find ( ident );
4383- if ( iter != mapSharedDS .end () )
4382+ auto iter = sMapSharedDS .find ( ident );
4383+ if ( iter != sMapSharedDS .end () )
43844384 {
43854385 if ( !canUseOpenedDatasets ( dsName ) )
43864386 {
43874387 QgsDebugMsg ( QString ( " Cannot reuse existing opened dataset(s) on %1 since it has been modified" ).arg ( dsName ) );
43884388 invalidateCachedDatasets ( dsName );
4389- iter = mapSharedDS .find ( ident );
4390- Q_ASSERT ( iter == mapSharedDS .end () );
4389+ iter = sMapSharedDS .find ( ident );
4390+ Q_ASSERT ( iter == sMapSharedDS .end () );
43914391 }
43924392 }
4393- if ( iter != mapSharedDS .end () )
4393+ if ( iter != sMapSharedDS .end () )
43944394 {
43954395 // Browse through this list, to look for a DatasetWithLayers*
43964396 // instance that don't use yet our layer of interest
@@ -4430,7 +4430,7 @@ QgsOgrLayerUniquePtr QgsOgrProviderUtils::getLayer( const QString &dsName,
44304430 errCause = QObject::tr ( " Cannot open %1." ).arg ( dsName );
44314431 return nullptr ;
44324432 }
4433- mapDSNameToLastModifiedDate [dsName] = getLastModified ( dsName );
4433+ sMapDSNameToLastModifiedDate [dsName] = getLastModified ( dsName );
44344434
44354435 OGRLayerH hLayer = GDALDatasetGetLayerByName (
44364436 hDS, layerName.toUtf8 ().constData () );
@@ -4460,7 +4460,7 @@ QgsOgrLayerUniquePtr QgsOgrProviderUtils::getLayer( const QString &dsName,
44604460 errCause = QObject::tr ( " Cannot open %1." ).arg ( dsName );
44614461 return nullptr ;
44624462 }
4463- mapDSNameToLastModifiedDate [dsName] = getLastModified ( dsName );
4463+ sMapDSNameToLastModifiedDate [dsName] = getLastModified ( dsName );
44644464
44654465 OGRLayerH hLayer = GDALDatasetGetLayerByName (
44664466 hDS, layerName.toUtf8 ().constData () );
@@ -4481,7 +4481,7 @@ QgsOgrLayerUniquePtr QgsOgrProviderUtils::getLayer( const QString &dsName,
44814481
44824482 QList<DatasetWithLayers *> datasetList;
44834483 datasetList.push_back ( ds );
4484- mapSharedDS [ident] = datasetList;
4484+ sMapSharedDS [ident] = datasetList;
44854485
44864486 return layer;
44874487}
@@ -4502,7 +4502,7 @@ void QgsOgrProviderUtils::release( QgsOgrLayer *&layer )
45024502 if ( !layer )
45034503 return ;
45044504
4505- QMutexLocker locker ( &globalMutex );
4505+ QMutexLocker locker ( &sGlobalMutex );
45064506
45074507 if ( !layer->isSqlLayer )
45084508 {
@@ -4521,8 +4521,8 @@ void QgsOgrProviderUtils::release( QgsOgrLayer *&layer )
45214521
45224522 if ( !layer->isSqlLayer )
45234523 {
4524- auto iter = mapSharedDS .find ( layer->ident );
4525- if ( iter != mapSharedDS .end () )
4524+ auto iter = sMapSharedDS .find ( layer->ident );
4525+ if ( iter != sMapSharedDS .end () )
45264526 {
45274527 auto &datasetList = iter.value ();
45284528 int i = 0 ;
@@ -4540,7 +4540,7 @@ void QgsOgrProviderUtils::release( QgsOgrLayer *&layer )
45404540 }
45414541
45424542 if ( datasetList.isEmpty () )
4543- mapSharedDS .erase ( iter );
4543+ sMapSharedDS .erase ( iter );
45444544 }
45454545 }
45464546 QgsOgrProviderUtils::GDALCloseWrapper ( layer->ds ->hDS );
0 commit comments