-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
qgsvectorlayer: Properly invalidate extent cache on feature addition
When a new feature is added to a `QgsVectorLayer` `QgsVectorLayer::addFeature` is called. This function makes mostly 2 things in case of a successful operation: 1. it calls `QgsVectorLayerEditBuffer::addFeature` which itself will emit the `QgsVectorLayerEditBuffer::featureAdded` signal. Finally, `QgsVectorLayer` listend to this signal to directly emit the `QgsVectorLayer::featureAdded` signal 2. Call `QgsVectorLayer::updateExtents()` to invalidate the cache of the extent In practice, this means that the `QgsVectorLayer::featureAdded` signal may be emitted before the cache of the extent is invalidated. This can cause some issues. For example, in the elevation profile tool, `QgsElevationProfileCanvas` listens to the `QgsVectorLayer::featureAdded` signal in order to regenerate the profile of a vector layer when a feature is added. This causes the creation of a new `QgsVectorLayerProfileGenerator` which needs to copy the extent of the vector layer. However, `QgsVectorLayer::updateExtents()` has not been called yet. Thus, it will use an outdated version of the extent. This issue is solved by calling `updateExtents()` before emitting the `featureAdded` signal.
- Loading branch information
1 parent
48b7079
commit 912bf7d
Showing
3 changed files
with
41 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters