Skip to content

Commit c913e83

Browse files
committedApr 29, 2016
Pass the full ogr data source URI as connInfo in qgsConnectionPool_ConnectionCreate.
This fixes corrupt rendering when loading the same dataset twice with different options (i.e. layers), see issue #14560.
1 parent dc94df5 commit c913e83

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed
 

‎src/providers/ogr/qgsogrconnpool.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ inline QString qgsConnectionPool_ConnectionToName( QgsOgrConn* c )
3535
inline void qgsConnectionPool_ConnectionCreate( QString connInfo, QgsOgrConn*& c )
3636
{
3737
c = new QgsOgrConn;
38-
c->ds = OGROpen( connInfo.toUtf8().constData(), false, nullptr );
38+
QString filePath = connInfo.left( connInfo.indexOf( "|" ) );
39+
c->ds = OGROpen( filePath.toUtf8().constData(), false, nullptr );
3940
c->path = connInfo;
4041
c->valid = true;
4142
}

‎src/providers/ogr/qgsogrfeatureiterator.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ QgsOgrFeatureIterator::QgsOgrFeatureIterator( QgsOgrFeatureSource* source, bool
4343
{
4444
mFeatureFetched = false;
4545

46-
mConn = QgsOgrConnPool::instance()->acquireConnection( mSource->mFilePath );
46+
mConn = QgsOgrConnPool::instance()->acquireConnection( mSource->mProvider->dataSourceUri() );
4747

4848
if ( mSource->mLayerName.isNull() )
4949
{
@@ -408,20 +408,20 @@ bool QgsOgrFeatureIterator::readFeature( OGRFeatureH fet, QgsFeature& feature )
408408
QgsOgrFeatureSource::QgsOgrFeatureSource( const QgsOgrProvider* p )
409409
: mProvider( p )
410410
{
411-
mFilePath = p->filePath();
411+
mDataSource = p->dataSourceUri();
412412
mLayerName = p->layerName();
413413
mLayerIndex = p->layerIndex();
414414
mSubsetString = p->mSubsetString;
415415
mEncoding = p->mEncoding; // no copying - this is a borrowed pointer from Qt
416416
mFields = p->mAttributeFields;
417417
mDriverName = p->ogrDriverName;
418418
mOgrGeometryTypeFilter = wkbFlatten( p->mOgrGeometryTypeFilter );
419-
QgsOgrConnPool::instance()->ref( mFilePath );
419+
QgsOgrConnPool::instance()->ref( mDataSource );
420420
}
421421

422422
QgsOgrFeatureSource::~QgsOgrFeatureSource()
423423
{
424-
QgsOgrConnPool::instance()->unref( mFilePath );
424+
QgsOgrConnPool::instance()->unref( mDataSource );
425425
}
426426

427427
QgsFeatureIterator QgsOgrFeatureSource::getFeatures( const QgsFeatureRequest& request )

‎src/providers/ogr/qgsogrfeatureiterator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class QgsOgrFeatureSource : public QgsAbstractFeatureSource
3434

3535
protected:
3636
const QgsOgrProvider* mProvider;
37-
QString mFilePath;
37+
QString mDataSource;
3838
QString mLayerName;
3939
int mLayerIndex;
4040
QString mSubsetString;

0 commit comments

Comments
 (0)
Please sign in to comment.