Skip to content
Permalink
Browse files

Ensure that full cache flag is cleared when invalid

On behalf of Faunalia, sponsored by ENEL
  • Loading branch information
nyalldawson committed Mar 5, 2017
1 parent acaf97c commit 36f190ca0bbe64a67bfd1627b7a22b31c7932b22
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();
}

@@ -242,6 +242,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()
@@ -375,6 +384,13 @@ void TestVectorLayerCache::testCacheGeom()
{
QVERIFY( f.hasGeometry() );
}

// 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 36f190c

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