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

(cherry-picked from 36f190c)
  • Loading branch information
nyalldawson committed Mar 7, 2017
1 parent bae59b9 commit c55ffd5
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 )
Expand Down

0 comments on commit c55ffd5

Please sign in to comment.