Skip to content

Commit

Permalink
Ensure that full cache flag is cleared when invalid
Browse files Browse the repository at this point in the history
On behalf of Faunalia, sponsored by ENEL
  • Loading branch information
nyalldawson committed Mar 5, 2017
1 parent acaf97c commit 36f190c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/core/qgsvectorlayercache.cpp
Expand Up @@ -237,6 +237,7 @@ void QgsVectorLayerCache::attributeAdded( int field )
{
Q_UNUSED( field )
mCachedAttributes.append( field );
mFullCache = false;
mCache.clear();
}

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

Expand Down
16 changes: 16 additions & 0 deletions tests/src/core/testqgsvectorlayercache.cpp
Expand Up @@ -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()
Expand Down Expand Up @@ -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 )
Expand Down

0 comments on commit 36f190c

Please sign in to comment.