Skip to content

Commit

Permalink
[FIX] Show attribute table for layers without geometry
Browse files Browse the repository at this point in the history
And add a message to the message log when an iterator is closed due to missing geometry
  • Loading branch information
m-kuhn committed Apr 2, 2013
1 parent 45b931b commit 1de8c76
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/gui/attributetable/qgsattributetablemodel.cpp
Expand Up @@ -36,6 +36,11 @@ QgsAttributeTableModel::QgsAttributeTableModel( QgsVectorLayerCache *layerCache,
{
QgsDebugMsg( "entered." );

if ( layerCache->layer()->geometryType() == QGis::NoGeometry )
{
mFeatureRequest.setFlags( QgsFeatureRequest::NoGeometry );
}

mFeat.setFeatureId( std::numeric_limits<int>::min() );

loadAttributes();
Expand Down Expand Up @@ -302,7 +307,7 @@ void QgsAttributeTableModel::loadLayer()
removeRows( 0, rowCount() );
endRemoveRows();

QgsFeatureIterator features = layer()->getFeatures( mFeatureRequest );
QgsFeatureIterator features = mLayerCache->getFeatures( mFeatureRequest );

int i = 0;

Expand Down
1 change: 1 addition & 0 deletions src/providers/postgres/qgspostgresfeatureiterator.cpp
Expand Up @@ -296,6 +296,7 @@ bool QgsPostgresFeatureIterator::declareCursor( const QString& whereClause )
bool fetchGeometry = !( mRequest.flags() & QgsFeatureRequest::NoGeometry );
if ( fetchGeometry && P->mGeometryColumn.isNull() )
{
QgsMessageLog::logMessage( QObject::tr( "Trying to fetch geometry on a layer without geometry." ), QObject::tr( "PostgreSQL" ) );
return false;
}

Expand Down

0 comments on commit 1de8c76

Please sign in to comment.