Skip to content
Permalink
Browse files

Ensure that full cache flag is cleared when invalid

On behalf of Faunalia, sponsored by ENEL

(cherry-picked from 36f190c)
  • Loading branch information
nyalldawson committed Mar 7, 2017
1 parent bae59b9 commit c55ffd5ad87b8ec2ecfb9ea62a7f26b86a1e7b45
Showing with 18 additions and 0 deletions.
  1. +2 −0 src/core/qgsvectorlayercache.cpp
  2. +16 −0 tests/src/core/testqgsvectorlayercache.cpp
@@ -237,6 +237,7 @@ void QgsVectorLayerCache::attributeAdded( int field )
{
Q_UNUSED( field )
mCachedAttributes.append( field );
mFullCache = false;
mCache.clear();
}

@@ -273,6 +274,7 @@ void QgsVectorLayerCache::layerDeleted()
void QgsVectorLayerCache::invalidate()
{
mCache.clear();
mFullCache = false;
emit invalidated();
}

@@ -241,6 +241,15 @@ void TestVectorLayerCache::testFullCache()
{
QVERIFY( cache.isFidCached( f.id() ) );
}

// add a feature to the layer
mPointsLayer->startEditing();
QgsFeature f2( mPointsLayer->fields() );
QVERIFY( mPointsLayer->addFeature( f2 ) );
QVERIFY( cache.hasFullCache() );
QVERIFY( cache.isFidCached( f2.id() ) );

mPointsLayer->rollBack();
}

void TestVectorLayerCache::testFullCacheThroughRequest()
@@ -374,6 +383,13 @@ void TestVectorLayerCache::testCacheGeom()
{
QVERIFY( f.constGeometry() );
}

// another test...
cache.setCacheGeometry( false );
cache.setFullCache( true );
QVERIFY( cache.hasFullCache() );
cache.setCacheGeometry( true );
QVERIFY( !cache.hasFullCache() );
}

void TestVectorLayerCache::onCommittedFeaturesAdded( const QString& layerId, const QgsFeatureList& features )

0 comments on commit c55ffd5

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