Skip to content

Commit

Permalink
vector cache: don't try to request geometries, if there aren't any
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Apr 2, 2013
1 parent 6e6b8fe commit 2b0d3e7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/core/qgsvectorlayercache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ int QgsVectorLayerCache::cacheSize()

void QgsVectorLayerCache::setCacheGeometry( bool cacheGeometry )
{
mCacheGeometry = cacheGeometry;
mCacheGeometry = cacheGeometry && mLayer->hasGeometryType();
if ( cacheGeometry )
{
connect( mLayer, SIGNAL( geometryChanged( QgsFeatureId, QgsGeometry& ) ), SLOT( geometryChanged( QgsFeatureId, QgsGeometry& ) ) );
Expand Down Expand Up @@ -277,7 +277,7 @@ bool QgsVectorLayerCache::checkInformationCovered( const QgsFeatureRequest& feat
{
QgsAttributeList requestedAttributes;

if ( false == featureRequest.flags().testFlag( QgsFeatureRequest::SubsetOfAttributes ) )
if ( !featureRequest.flags().testFlag( QgsFeatureRequest::SubsetOfAttributes ) )
{
requestedAttributes = mLayer->pendingAllAttributesList();
}
Expand All @@ -296,8 +296,8 @@ bool QgsVectorLayerCache::checkInformationCovered( const QgsFeatureRequest& feat
}

// If the request needs geometry but we don't cache this...
if ( false == featureRequest.flags().testFlag( QgsFeatureRequest::NoGeometry )
&& false == mCacheGeometry )
if ( !featureRequest.flags().testFlag( QgsFeatureRequest::NoGeometry )
&& !mCacheGeometry )
{
return false;
}
Expand Down
7 changes: 5 additions & 2 deletions src/gui/attributetable/qgsattributetablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,16 @@
#include <limits>

QgsAttributeTableModel::QgsAttributeTableModel( QgsVectorLayerCache *layerCache, QObject *parent )
: QAbstractTableModel( parent ),
mLayerCache( layerCache )
: QAbstractTableModel( parent )
, mLayerCache( layerCache )
{
QgsDebugMsg( "entered." );

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

if ( !layer()->hasGeometryType() )
mFeatureRequest.setFlags( QgsFeatureRequest::NoGeometry );

loadAttributes();

connect( layer(), SIGNAL( attributeValueChanged( QgsFeatureId, int, const QVariant& ) ), this, SLOT( attributeValueChanged( QgsFeatureId, int, const QVariant& ) ) );
Expand Down

0 comments on commit 2b0d3e7

Please sign in to comment.