Skip to content

Commit c55ffd5

Browse files
committedMar 7, 2017
Ensure that full cache flag is cleared when invalid
On behalf of Faunalia, sponsored by ENEL (cherry-picked from 36f190c)
1 parent bae59b9 commit c55ffd5

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed
 

‎src/core/qgsvectorlayercache.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ void QgsVectorLayerCache::attributeAdded( int field )
237237
{
238238
Q_UNUSED( field )
239239
mCachedAttributes.append( field );
240+
mFullCache = false;
240241
mCache.clear();
241242
}
242243

@@ -273,6 +274,7 @@ void QgsVectorLayerCache::layerDeleted()
273274
void QgsVectorLayerCache::invalidate()
274275
{
275276
mCache.clear();
277+
mFullCache = false;
276278
emit invalidated();
277279
}
278280

‎tests/src/core/testqgsvectorlayercache.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,15 @@ void TestVectorLayerCache::testFullCache()
241241
{
242242
QVERIFY( cache.isFidCached( f.id() ) );
243243
}
244+
245+
// add a feature to the layer
246+
mPointsLayer->startEditing();
247+
QgsFeature f2( mPointsLayer->fields() );
248+
QVERIFY( mPointsLayer->addFeature( f2 ) );
249+
QVERIFY( cache.hasFullCache() );
250+
QVERIFY( cache.isFidCached( f2.id() ) );
251+
252+
mPointsLayer->rollBack();
244253
}
245254

246255
void TestVectorLayerCache::testFullCacheThroughRequest()
@@ -374,6 +383,13 @@ void TestVectorLayerCache::testCacheGeom()
374383
{
375384
QVERIFY( f.constGeometry() );
376385
}
386+
387+
// another test...
388+
cache.setCacheGeometry( false );
389+
cache.setFullCache( true );
390+
QVERIFY( cache.hasFullCache() );
391+
cache.setCacheGeometry( true );
392+
QVERIFY( !cache.hasFullCache() );
377393
}
378394

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

0 commit comments

Comments
 (0)
Please sign in to comment.