Skip to content

Commit 36f190c

Browse files
committed
Ensure that full cache flag is cleared when invalid
On behalf of Faunalia, sponsored by ENEL
1 parent acaf97c commit 36f190c

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/core/qgsvectorlayercache.cpp

+2
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

+16
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,15 @@ void TestVectorLayerCache::testFullCache()
242242
{
243243
QVERIFY( cache.isFidCached( f.id() ) );
244244
}
245+
246+
// add a feature to the layer
247+
mPointsLayer->startEditing();
248+
QgsFeature f2( mPointsLayer->fields() );
249+
QVERIFY( mPointsLayer->addFeature( f2 ) );
250+
QVERIFY( cache.hasFullCache() );
251+
QVERIFY( cache.isFidCached( f2.id() ) );
252+
253+
mPointsLayer->rollBack();
245254
}
246255

247256
void TestVectorLayerCache::testFullCacheThroughRequest()
@@ -375,6 +384,13 @@ void TestVectorLayerCache::testCacheGeom()
375384
{
376385
QVERIFY( f.hasGeometry() );
377386
}
387+
388+
// another test...
389+
cache.setCacheGeometry( false );
390+
cache.setFullCache( true );
391+
QVERIFY( cache.hasFullCache() );
392+
cache.setCacheGeometry( true );
393+
QVERIFY( !cache.hasFullCache() );
378394
}
379395

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

0 commit comments

Comments
 (0)