@@ -53,6 +53,7 @@ class TestVectorLayerCache : public QObject
53
53
void testFullCacheThroughRequest ();
54
54
void testCanUseCacheForRequest ();
55
55
void testCacheGeom ();
56
+ void testFullCacheWithRect (); // Test that if rect is set then no full cache can exist, see #19468
56
57
57
58
void onCommittedFeaturesAdded ( const QString &, const QgsFeatureList & );
58
59
@@ -390,6 +391,33 @@ void TestVectorLayerCache::testCacheGeom()
390
391
QVERIFY ( !cache.hasFullCache () );
391
392
}
392
393
394
+ void TestVectorLayerCache::testFullCacheWithRect ()
395
+ {
396
+ QgsVectorLayerCache cache ( mPointsLayer , mPointsLayer ->dataProvider ()->featureCount () );
397
+ // cache geometry
398
+ cache.setCacheGeometry ( true );
399
+ QVERIFY ( ! cache.hasFullCache () );
400
+ QgsFeatureRequest req;
401
+ req.setFilterRect ( mPointsLayer ->dataProvider ()->extent ().buffered ( - mPointsLayer ->dataProvider ()->extent ().width () / 2 ) );
402
+ QgsFeatureIterator it = cache.getFeatures ( req );
403
+ QgsFeature f;
404
+ while ( it.nextFeature ( f ) )
405
+ {
406
+ QVERIFY ( f.hasGeometry () );
407
+ }
408
+ QVERIFY ( ! cache.hasFullCache () );
409
+
410
+ // Filter rect contains extent
411
+ req.setFilterRect ( mPointsLayer ->dataProvider ()->extent ().buffered ( 1 ) );
412
+ it = cache.getFeatures ( req );
413
+ while ( it.nextFeature ( f ) )
414
+ {
415
+ QVERIFY ( f.hasGeometry () );
416
+ }
417
+ QVERIFY ( cache.hasFullCache () );
418
+
419
+ }
420
+
393
421
void TestVectorLayerCache::onCommittedFeaturesAdded ( const QString &layerId, const QgsFeatureList &features )
394
422
{
395
423
Q_UNUSED ( layerId )
0 commit comments