@@ -457,21 +457,33 @@ QgsOgrProvider::QgsOgrProvider( QString const &uri )
457
457
458
458
setNativeTypes ( nativeTypes );
459
459
460
- QgsOgrConnPool::instance ()->ref( QgsOgrProviderUtils::connectionPoolId( dataSourceUri() ) );
460
+ QgsOgrConnPool::instance ()->ref( QgsOgrProviderUtils::connectionPoolId( dataSourceUri( true ) ) );
461
461
}
462
462
463
463
QgsOgrProvider::~QgsOgrProvider ()
464
464
{
465
- QgsOgrConnPool::instance ()->unref ( QgsOgrProviderUtils::connectionPoolId ( dataSourceUri () ) );
465
+ QgsOgrConnPool::instance ()->unref ( QgsOgrProviderUtils::connectionPoolId ( dataSourceUri ( true ) ) );
466
466
// We must also make sure to flush unusef cached connections so that
467
467
// the file can be removed (#15137)
468
- QgsOgrConnPool::instance ()->invalidateConnections ( QgsOgrProviderUtils::connectionPoolId ( dataSourceUri () ) );
468
+ QgsOgrConnPool::instance ()->invalidateConnections ( QgsOgrProviderUtils::connectionPoolId ( dataSourceUri ( true ) ) );
469
469
470
470
// Do that as last step for final cleanup that might be prevented by
471
471
// still opened datasets.
472
472
close ();
473
473
}
474
474
475
+ QString QgsOgrProvider::dataSourceUri ( bool expandAuthConfig ) const
476
+ {
477
+ if ( expandAuthConfig && QgsDataProvider::dataSourceUri ( ).contains ( QLatin1String ( " authcfg" ) ) )
478
+ {
479
+ return QgsOgrProviderUtils::expandAuthConfig ( QgsDataProvider::dataSourceUri ( ) );
480
+ }
481
+ else
482
+ {
483
+ return QgsDataProvider::dataSourceUri ( );
484
+ }
485
+ }
486
+
475
487
QgsAbstractFeatureSource *QgsOgrProvider::featureSource () const
476
488
{
477
489
return new QgsOgrFeatureSource ( this );
@@ -537,9 +549,9 @@ bool QgsOgrProvider::setSubsetString( const QString &theSQL, bool updateFeatureC
537
549
538
550
if ( uri != dataSourceUri () )
539
551
{
540
- QgsOgrConnPool::instance ()->unref ( QgsOgrProviderUtils::connectionPoolId ( dataSourceUri () ) );
552
+ QgsOgrConnPool::instance ()->unref ( QgsOgrProviderUtils::connectionPoolId ( dataSourceUri ( true ) ) );
541
553
setDataSourceUri ( uri );
542
- QgsOgrConnPool::instance ()->ref ( QgsOgrProviderUtils::connectionPoolId ( dataSourceUri () ) );
554
+ QgsOgrConnPool::instance ()->ref ( QgsOgrProviderUtils::connectionPoolId ( dataSourceUri ( true ) ) );
543
555
}
544
556
545
557
mOgrLayer ->ResetReading ();
@@ -889,7 +901,7 @@ OGRwkbGeometryType QgsOgrProvider::getOgrGeomType( OGRLayerH ogrLayer )
889
901
890
902
void QgsOgrProvider::loadFields ()
891
903
{
892
- QgsOgrConnPool::instance ()->invalidateConnections ( QgsOgrProviderUtils::connectionPoolId ( dataSourceUri () ) );
904
+ QgsOgrConnPool::instance ()->invalidateConnections ( QgsOgrProviderUtils::connectionPoolId ( dataSourceUri ( true ) ) );
893
905
// the attribute fields need to be read again when the encoding changes
894
906
mAttributeFields .clear ();
895
907
mDefaultValues .clear ();
@@ -1458,7 +1470,7 @@ bool QgsOgrProvider::addAttributes( const QList<QgsField> &attributes )
1458
1470
{
1459
1471
// adding attributes in mapinfo requires to be able to delete the .dat file
1460
1472
// so drop any cached connections.
1461
- QgsOgrConnPool::instance ()->invalidateConnections ( QgsOgrProviderUtils::connectionPoolId ( dataSourceUri () ) );
1473
+ QgsOgrConnPool::instance ()->invalidateConnections ( QgsOgrProviderUtils::connectionPoolId ( dataSourceUri ( true ) ) );
1462
1474
}
1463
1475
1464
1476
bool returnvalue = true ;
@@ -1792,7 +1804,7 @@ bool QgsOgrProvider::changeAttributeValues( const QgsChangedAttributesMap &attr_
1792
1804
{
1793
1805
pushError ( tr ( " OGR error syncing to disk: %1" ).arg ( CPLGetLastErrorMsg () ) );
1794
1806
}
1795
- QgsOgrConnPool::instance ()->invalidateConnections ( QgsOgrProviderUtils::connectionPoolId ( dataSourceUri () ) );
1807
+ QgsOgrConnPool::instance ()->invalidateConnections ( QgsOgrProviderUtils::connectionPoolId ( dataSourceUri ( true ) ) );
1796
1808
return true ;
1797
1809
}
1798
1810
@@ -1868,7 +1880,7 @@ bool QgsOgrProvider::changeGeometryValues( const QgsGeometryMap &geometry_map )
1868
1880
commitTransaction ();
1869
1881
}
1870
1882
1871
- QgsOgrConnPool::instance ()->invalidateConnections ( QgsOgrProviderUtils::connectionPoolId ( dataSourceUri () ) );
1883
+ QgsOgrConnPool::instance ()->invalidateConnections ( QgsOgrProviderUtils::connectionPoolId ( dataSourceUri ( true ) ) );
1872
1884
return syncToDisc ();
1873
1885
}
1874
1886
@@ -3261,7 +3273,7 @@ QByteArray QgsOgrProvider::quotedIdentifier( const QByteArray &field ) const
3261
3273
3262
3274
void QgsOgrProvider::forceReload ()
3263
3275
{
3264
- QgsOgrConnPool::instance ()->invalidateConnections ( QgsOgrProviderUtils::connectionPoolId ( dataSourceUri () ) );
3276
+ QgsOgrConnPool::instance ()->invalidateConnections ( QgsOgrProviderUtils::connectionPoolId ( dataSourceUri ( true ) ) );
3265
3277
}
3266
3278
3267
3279
QString QgsOgrProviderUtils::connectionPoolId ( const QString &dataSourceURI )
@@ -3539,7 +3551,7 @@ QString QgsOgrProviderUtils::quotedValue( const QVariant &value )
3539
3551
bool QgsOgrProvider::syncToDisc ()
3540
3552
{
3541
3553
// for shapefiles, remove spatial index files and create a new index
3542
- QgsOgrConnPool::instance ()->unref ( QgsOgrProviderUtils::connectionPoolId ( dataSourceUri () ) );
3554
+ QgsOgrConnPool::instance ()->unref ( QgsOgrProviderUtils::connectionPoolId ( dataSourceUri ( true ) ) );
3543
3555
bool shapeIndex = false ;
3544
3556
if ( mGDALDriverName == QLatin1String ( " ESRI Shapefile" ) )
3545
3557
{
@@ -3554,7 +3566,7 @@ bool QgsOgrProvider::syncToDisc()
3554
3566
{
3555
3567
shapeIndex = true ;
3556
3568
close ();
3557
- QgsOgrConnPool::instance ()->invalidateConnections ( QgsOgrProviderUtils::connectionPoolId ( dataSourceUri () ) );
3569
+ QgsOgrConnPool::instance ()->invalidateConnections ( QgsOgrProviderUtils::connectionPoolId ( dataSourceUri ( true ) ) );
3558
3570
QFile::remove ( sbnIndexFile );
3559
3571
open ( OpenModeSameAsCurrent );
3560
3572
if ( !mValid )
@@ -3578,7 +3590,7 @@ bool QgsOgrProvider::syncToDisc()
3578
3590
}
3579
3591
#endif
3580
3592
3581
- QgsOgrConnPool::instance ()->ref ( QgsOgrProviderUtils::connectionPoolId ( dataSourceUri () ) );
3593
+ QgsOgrConnPool::instance ()->ref ( QgsOgrProviderUtils::connectionPoolId ( dataSourceUri ( true ) ) );
3582
3594
if ( shapeIndex )
3583
3595
{
3584
3596
return createSpatialIndex ();
@@ -3640,7 +3652,7 @@ void QgsOgrProvider::recalculateFeatureCount()
3640
3652
mOgrLayer ->SetSpatialFilter ( filter );
3641
3653
}
3642
3654
3643
- QgsOgrConnPool::instance ()->invalidateConnections ( QgsOgrProviderUtils::connectionPoolId ( dataSourceUri () ) );
3655
+ QgsOgrConnPool::instance ()->invalidateConnections ( QgsOgrProviderUtils::connectionPoolId ( dataSourceUri ( true ) ) );
3644
3656
}
3645
3657
3646
3658
bool QgsOgrProvider::doesStrictFeatureTypeCheck () const
@@ -3753,9 +3765,6 @@ void QgsOgrProvider::open( OpenMode mode )
3753
3765
Q_ASSERT ( !mOgrLayer );
3754
3766
Q_ASSERT ( !mOgrOrigLayer );
3755
3767
3756
- // Expand authentication
3757
- setDataSourceUri ( QgsOgrProviderUtils::expandAuthConfig ( mFilePath ) );
3758
-
3759
3768
// Try to open using VSIFileHandler
3760
3769
// see http://trac.osgeo.org/gdal/wiki/UserDocs/ReadInZip
3761
3770
QString vsiPrefix = QgsZipItem::vsiPrefix ( dataSourceUri () );
0 commit comments