Skip to content
Permalink
Browse files

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 10, 2016
1 parent dc94df5 commit c913e83f5ad14b011be0a44ec9a59d80d103f929
@@ -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;
}
@@ -43,7 +43,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() )
{
@@ -408,20 +408,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 )
@@ -34,7 +34,7 @@ class QgsOgrFeatureSource : public QgsAbstractFeatureSource

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

0 comments on commit c913e83

Please sign in to comment.
You can’t perform that action at this time.