-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix inconsistency between layer providers in geometry checker #58132
Changes from all commits
3393264
57fce5a
cf0da99
542c10a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,6 +108,9 @@ bool QgsVectorLayerFeaturePool::addFeatures( QgsFeatureList &features, QgsFeatur | |
|
||
void QgsVectorLayerFeaturePool::updateFeature( QgsFeature &feature ) | ||
{ | ||
QgsFeature origFeature; | ||
getFeature( feature.id(), origFeature ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I may be getting confused here, but I think there's still a risk of index corruption in this scenario:
I don't see any alternative but keeping a local map/hash of the feature bounds which were used in the index. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right, I did not expect that the spatial index could evict a feature... It is an index, not strictly a cache, isn't it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It won't get evicted from the spatial index, but will from mFeatureCache. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Of course 🙈 obviously. Okay, what about "synchronizing" the cache and the index? In fact, in the end of step 4. inside the index, we have both feature A version 2 and feature A version 1. We could fix this: when getFeature doesn't find a cached feature, we can proactively delete any pre-existing corresponding feature in the index (see new commit). If the feature was not present in the index, it does nearly nothing, otherwise it removes the possibly out-of-date feature from the index, to re-add the possibly same or up-to-date feature. |
||
|
||
QgsThreadingUtils::runOnMainThread( [this, &feature]() | ||
{ | ||
QgsVectorLayer *lyr = layer(); | ||
|
@@ -117,7 +120,7 @@ void QgsVectorLayerFeaturePool::updateFeature( QgsFeature &feature ) | |
} | ||
} ); | ||
|
||
refreshCache( feature ); | ||
refreshCache( feature, origFeature ); | ||
} | ||
|
||
void QgsVectorLayerFeaturePool::deleteFeature( QgsFeatureId fid ) | ||
|
@@ -135,14 +138,17 @@ void QgsVectorLayerFeaturePool::deleteFeature( QgsFeatureId fid ) | |
|
||
void QgsVectorLayerFeaturePool::onGeometryChanged( QgsFeatureId fid, const QgsGeometry &geometry ) | ||
{ | ||
Q_UNUSED( geometry ) | ||
|
||
QgsFeature feature; | ||
if ( isFeatureCached( fid ) ) | ||
{ | ||
QgsFeature feature; | ||
getFeature( fid, feature ); | ||
refreshCache( feature ); | ||
QgsFeature origFeature; | ||
getFeature( fid, origFeature ); // gets the cached feature | ||
feature = origFeature; | ||
feature.setGeometry( geometry ); | ||
refreshCache( feature, origFeature ); | ||
} | ||
else | ||
getFeature( fid, feature ); // gets the feature and adds it to the cache and index | ||
} | ||
|
||
void QgsVectorLayerFeaturePool::onFeatureDeleted( QgsFeatureId fid ) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The index isn't created with the FlagStoreFeatureGeometries flag, so this will always be null.
Can you please add some tests before trying more solutions? Right now we're just fumbling in the dark 🤣
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The index creation here https://github.com/qgis/QGIS/blob/master/src/analysis/vector/geometry_checker/qgsfeaturepool.cpp#L82 has default flags which seems ON for FlagStoreFeatureGeometries https://github.com/qgis/QGIS/blob/master/src/core/qgsspatialindex.h#L77
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not how qflags work 😂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...yes I was expecting that 😆 writing a test at the moment... ^^