mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-28 00:17:30 -05:00
Do not set full layer cache when a filter rect is passed
Fixes #19468 - Attribute table: show features visible on map is broken (and affects show all features, too)
This commit is contained in:
parent
1a94727dbe
commit
929ab27282
@ -205,11 +205,12 @@ void QgsVectorLayerCache::requestCompleted( const QgsFeatureRequest &featureRequ
|
|||||||
// If a request is too large for the cache don't notify to prevent from indexing incomplete requests
|
// If a request is too large for the cache don't notify to prevent from indexing incomplete requests
|
||||||
if ( fids.count() <= mCache.size() )
|
if ( fids.count() <= mCache.size() )
|
||||||
{
|
{
|
||||||
Q_FOREACH ( QgsAbstractCacheIndex *idx, mCacheIndices )
|
for ( const auto &idx : qgis::as_const( mCacheIndices ) )
|
||||||
{
|
{
|
||||||
idx->requestCompleted( featureRequest, fids );
|
idx->requestCompleted( featureRequest, fids );
|
||||||
}
|
}
|
||||||
if ( featureRequest.filterType() == QgsFeatureRequest::FilterNone )
|
if ( featureRequest.filterType() == QgsFeatureRequest::FilterNone &&
|
||||||
|
( featureRequest.filterRect().isNull() || featureRequest.filterRect().contains( mLayer->extent() ) ) )
|
||||||
{
|
{
|
||||||
mFullCache = true;
|
mFullCache = true;
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,7 @@ class TestVectorLayerCache : public QObject
|
|||||||
void testFullCacheThroughRequest();
|
void testFullCacheThroughRequest();
|
||||||
void testCanUseCacheForRequest();
|
void testCanUseCacheForRequest();
|
||||||
void testCacheGeom();
|
void testCacheGeom();
|
||||||
|
void testFullCacheWithRect(); // Test that if rect is set then no full cache can exist, see #19468
|
||||||
|
|
||||||
void onCommittedFeaturesAdded( const QString &, const QgsFeatureList & );
|
void onCommittedFeaturesAdded( const QString &, const QgsFeatureList & );
|
||||||
|
|
||||||
@ -390,6 +391,33 @@ void TestVectorLayerCache::testCacheGeom()
|
|||||||
QVERIFY( !cache.hasFullCache() );
|
QVERIFY( !cache.hasFullCache() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestVectorLayerCache::testFullCacheWithRect()
|
||||||
|
{
|
||||||
|
QgsVectorLayerCache cache( mPointsLayer, mPointsLayer->dataProvider()->featureCount() );
|
||||||
|
// cache geometry
|
||||||
|
cache.setCacheGeometry( true );
|
||||||
|
QVERIFY( ! cache.hasFullCache() );
|
||||||
|
QgsFeatureRequest req;
|
||||||
|
req.setFilterRect( mPointsLayer->dataProvider()->extent().buffered( - mPointsLayer->dataProvider()->extent().width() / 2 ) );
|
||||||
|
QgsFeatureIterator it = cache.getFeatures( req );
|
||||||
|
QgsFeature f;
|
||||||
|
while ( it.nextFeature( f ) )
|
||||||
|
{
|
||||||
|
QVERIFY( f.hasGeometry() );
|
||||||
|
}
|
||||||
|
QVERIFY( ! cache.hasFullCache() );
|
||||||
|
|
||||||
|
// Filter rect contains extent
|
||||||
|
req.setFilterRect( mPointsLayer->dataProvider()->extent().buffered( 1 ) );
|
||||||
|
it = cache.getFeatures( req );
|
||||||
|
while ( it.nextFeature( f ) )
|
||||||
|
{
|
||||||
|
QVERIFY( f.hasGeometry() );
|
||||||
|
}
|
||||||
|
QVERIFY( cache.hasFullCache() );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void TestVectorLayerCache::onCommittedFeaturesAdded( const QString &layerId, const QgsFeatureList &features )
|
void TestVectorLayerCache::onCommittedFeaturesAdded( const QString &layerId, const QgsFeatureList &features )
|
||||||
{
|
{
|
||||||
Q_UNUSED( layerId )
|
Q_UNUSED( layerId )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user