@@ -53,6 +53,7 @@ class TestVectorLayerCache : public QObject
5353 void testFullCacheThroughRequest ();
5454 void testCanUseCacheForRequest ();
5555 void testCacheGeom ();
56+ void testFullCacheWithRect (); // Test that if rect is set then no full cache can exist, see #19468
5657
5758 void onCommittedFeaturesAdded ( const QString &, const QgsFeatureList & );
5859
@@ -390,6 +391,33 @@ void TestVectorLayerCache::testCacheGeom()
390391 QVERIFY ( !cache.hasFullCache () );
391392}
392393
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+
393421void TestVectorLayerCache::onCommittedFeaturesAdded ( const QString &layerId, const QgsFeatureList &features )
394422{
395423 Q_UNUSED ( layerId )
0 commit comments