Skip to content

Commit edbfb57

Browse files
m-kuhnMatthias Kuhn
authored and
Matthias Kuhn
committed
VLCache takes ownership of index
1 parent 73d69f2 commit edbfb57

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/core/qgsvectorlayercache.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ QgsVectorLayerCache::QgsVectorLayerCache( QgsVectorLayer* layer, int cacheSize,
3939
connect( mLayer, SIGNAL( attributeValueChanged( QgsFeatureId, int, const QVariant& ) ), SLOT( onAttributeValueChanged( QgsFeatureId, int, const QVariant& ) ) );
4040
}
4141

42+
QgsVectorLayerCache::~QgsVectorLayerCache()
43+
{
44+
qDeleteAll( mCacheIndices );
45+
mCacheIndices.clear();
46+
}
47+
4248
void QgsVectorLayerCache::setCacheSize( int cacheSize )
4349
{
4450
mCache.setMaxCost( cacheSize );
@@ -178,7 +184,7 @@ void QgsVectorLayerCache::requestCompleted( QgsFeatureRequest featureRequest, Qg
178184

179185
void QgsVectorLayerCache::featureRemoved( QgsFeatureId fid )
180186
{
181-
foreach ( QgsAbstractCacheIndex* idx, mCacheIndices )
187+
Q_FOREACH( QgsAbstractCacheIndex* idx, mCacheIndices )
182188
{
183189
idx->flushFeature( fid );
184190
}

src/core/qgsvectorlayercache.h

+4
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ class CORE_EXPORT QgsVectorLayerCache : public QObject
8686
*
8787
* @param cacheSize indicates the maximum number of features to keep in the cache
8888
*/
89+
90+
~QgsVectorLayerCache();
91+
8992
void setCacheSize( int cacheSize );
9093

9194
/**
@@ -136,6 +139,7 @@ class CORE_EXPORT QgsVectorLayerCache : public QObject
136139
* @brief
137140
* Adds a {@link QgsAbstractCacheIndex} to this cache. Cache indices know about features present
138141
* in this cache and decide, if enough information is present in the cache to respond to a {@link QgsFeatureRequest}.
142+
* The layer cache will take ownership of the index.
139143
*
140144
* @param cacheIndex The cache index to add.
141145
*/

0 commit comments

Comments
 (0)