Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[OGR provider] subLayers(): avoid emitting error on a geometry less l…
…ayer
  • Loading branch information
rouault committed Oct 20, 2017
1 parent c130f9f commit feaa8b8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/providers/ogr/qgsogrprovider.cpp
Expand Up @@ -696,9 +696,9 @@ void QgsOgrProvider::addSubLayerDetailsToSubLayerList( int i, QgsOgrLayer *layer
// Get first column name,
// TODO: add support for multiple
QString geometryColumnName;
OGRGeomFieldDefnH geomH = fdef.GetGeomFieldDefn( 0 );
if ( geomH )
if ( fdef.GetGeomFieldCount() )
{
OGRGeomFieldDefnH geomH = fdef.GetGeomFieldDefn( 0 );
geometryColumnName = QString::fromUtf8( OGR_GFld_GetNameRef( geomH ) );
}
QString layerName = QString::fromUtf8( layer->name() );
Expand Down Expand Up @@ -4648,6 +4648,12 @@ int QgsOgrFeatureDefn::GetFieldIndex( const QByteArray &name )
return OGR_FD_GetFieldIndex( get(), name.constData() );
}

int QgsOgrFeatureDefn::GetGeomFieldCount()
{
QMutexLocker locker( &mutex() );
return OGR_FD_GetGeomFieldCount( get() );
}

OGRGeomFieldDefnH QgsOgrFeatureDefn::GetGeomFieldDefn( int idx )
{
QMutexLocker locker( &mutex() );
Expand Down
3 changes: 3 additions & 0 deletions src/providers/ogr/qgsogrprovider.h
Expand Up @@ -402,6 +402,9 @@ class QgsOgrFeatureDefn
//! Wrapper of OGR_FD_GetFieldIndex
int GetFieldIndex( const QByteArray & );

//! Wrapper of OGR_FD_GetGeomFieldCount
int GetGeomFieldCount();

//! Wrapper of OGR_FD_GetGeomFieldDefn
OGRGeomFieldDefnH GetGeomFieldDefn( int idx );

Expand Down

0 comments on commit feaa8b8

Please sign in to comment.