Skip to content

Commit 79493ea

Browse files
committedApr 26, 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 2ba252b commit 79493ea

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
@@ -44,7 +44,7 @@ QgsOgrFeatureIterator::QgsOgrFeatureIterator( QgsOgrFeatureSource* source, bool
4444
{
4545
mFeatureFetched = false;
4646

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

4949
if ( mSource->mLayerName.isNull() )
5050
{
@@ -348,20 +348,20 @@ bool QgsOgrFeatureIterator::readFeature( OGRFeatureH fet, QgsFeature& feature )
348348
QgsOgrFeatureSource::QgsOgrFeatureSource( const QgsOgrProvider* p )
349349
: mProvider( p )
350350
{
351-
mFilePath = p->filePath();
351+
mDataSource = p->dataSourceUri();
352352
mLayerName = p->layerName();
353353
mLayerIndex = p->layerIndex();
354354
mSubsetString = p->mSubsetString;
355355
mEncoding = p->mEncoding; // no copying - this is a borrowed pointer from Qt
356356
mFields = p->mAttributeFields;
357357
mDriverName = p->ogrDriverName;
358358
mOgrGeometryTypeFilter = wkbFlatten( p->mOgrGeometryTypeFilter );
359-
QgsOgrConnPool::instance()->ref( mFilePath );
359+
QgsOgrConnPool::instance()->ref( mDataSource );
360360
}
361361

362362
QgsOgrFeatureSource::~QgsOgrFeatureSource()
363363
{
364-
QgsOgrConnPool::instance()->unref( mFilePath );
364+
QgsOgrConnPool::instance()->unref( mDataSource );
365365
}
366366

367367
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)
Failed to load comments.