Skip to content

Commit 2b0d3e7

Browse files
committed
vector cache: don't try to request geometries, if there aren't any
1 parent 6e6b8fe commit 2b0d3e7

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/core/qgsvectorlayercache.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ int QgsVectorLayerCache::cacheSize()
4949

5050
void QgsVectorLayerCache::setCacheGeometry( bool cacheGeometry )
5151
{
52-
mCacheGeometry = cacheGeometry;
52+
mCacheGeometry = cacheGeometry && mLayer->hasGeometryType();
5353
if ( cacheGeometry )
5454
{
5555
connect( mLayer, SIGNAL( geometryChanged( QgsFeatureId, QgsGeometry& ) ), SLOT( geometryChanged( QgsFeatureId, QgsGeometry& ) ) );
@@ -277,7 +277,7 @@ bool QgsVectorLayerCache::checkInformationCovered( const QgsFeatureRequest& feat
277277
{
278278
QgsAttributeList requestedAttributes;
279279

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

298298
// If the request needs geometry but we don't cache this...
299-
if ( false == featureRequest.flags().testFlag( QgsFeatureRequest::NoGeometry )
300-
&& false == mCacheGeometry )
299+
if ( !featureRequest.flags().testFlag( QgsFeatureRequest::NoGeometry )
300+
&& !mCacheGeometry )
301301
{
302302
return false;
303303
}

src/gui/attributetable/qgsattributetablemodel.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,16 @@
3131
#include <limits>
3232

3333
QgsAttributeTableModel::QgsAttributeTableModel( QgsVectorLayerCache *layerCache, QObject *parent )
34-
: QAbstractTableModel( parent ),
35-
mLayerCache( layerCache )
34+
: QAbstractTableModel( parent )
35+
, mLayerCache( layerCache )
3636
{
3737
QgsDebugMsg( "entered." );
3838

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

41+
if ( !layer()->hasGeometryType() )
42+
mFeatureRequest.setFlags( QgsFeatureRequest::NoGeometry );
43+
4144
loadAttributes();
4245

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

0 commit comments

Comments
 (0)