Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Pass the full ogr data source URI as connInfo in qgsConnectionPool_Co…
…nnectionCreate.

This fixes corrupt rendering when loading the same dataset twice with different options (i.e. layers), see issue #14560.
  • Loading branch information
manisandro committed Apr 26, 2016
1 parent 2ba252b commit 79493ea
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/providers/ogr/qgsogrconnpool.h
Expand Up @@ -35,7 +35,8 @@ inline QString qgsConnectionPool_ConnectionToName( QgsOgrConn* c )
inline void qgsConnectionPool_ConnectionCreate( QString connInfo, QgsOgrConn*& c )
{
c = new QgsOgrConn;
c->ds = OGROpen( connInfo.toUtf8().constData(), false, nullptr );
QString filePath = connInfo.left( connInfo.indexOf( "|" ) );
c->ds = OGROpen( filePath.toUtf8().constData(), false, nullptr );
c->path = connInfo;
c->valid = true;
}
Expand Down
8 changes: 4 additions & 4 deletions src/providers/ogr/qgsogrfeatureiterator.cpp
Expand Up @@ -44,7 +44,7 @@ QgsOgrFeatureIterator::QgsOgrFeatureIterator( QgsOgrFeatureSource* source, bool
{
mFeatureFetched = false;

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

if ( mSource->mLayerName.isNull() )
{
Expand Down Expand Up @@ -348,20 +348,20 @@ bool QgsOgrFeatureIterator::readFeature( OGRFeatureH fet, QgsFeature& feature )
QgsOgrFeatureSource::QgsOgrFeatureSource( const QgsOgrProvider* p )
: mProvider( p )
{
mFilePath = p->filePath();
mDataSource = p->dataSourceUri();
mLayerName = p->layerName();
mLayerIndex = p->layerIndex();
mSubsetString = p->mSubsetString;
mEncoding = p->mEncoding; // no copying - this is a borrowed pointer from Qt
mFields = p->mAttributeFields;
mDriverName = p->ogrDriverName;
mOgrGeometryTypeFilter = wkbFlatten( p->mOgrGeometryTypeFilter );
QgsOgrConnPool::instance()->ref( mFilePath );
QgsOgrConnPool::instance()->ref( mDataSource );
}

QgsOgrFeatureSource::~QgsOgrFeatureSource()
{
QgsOgrConnPool::instance()->unref( mFilePath );
QgsOgrConnPool::instance()->unref( mDataSource );
}

QgsFeatureIterator QgsOgrFeatureSource::getFeatures( const QgsFeatureRequest& request )
Expand Down
2 changes: 1 addition & 1 deletion src/providers/ogr/qgsogrfeatureiterator.h
Expand Up @@ -34,7 +34,7 @@ class QgsOgrFeatureSource : public QgsAbstractFeatureSource

protected:
const QgsOgrProvider* mProvider;
QString mFilePath;
QString mDataSource;
QString mLayerName;
int mLayerIndex;
QString mSubsetString;
Expand Down

2 comments on commit 79493ea

@nyalldawson
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@manisandro can this be backported for the 2.14.2 release? (due today!)

@manisandro
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nyalldawson Done (hope still on time)

Please sign in to comment.