Bug report #15505
Wrong result returned by layer.getFeatures(request) in editing mode when setting limit on request
Status: | Closed | ||
---|---|---|---|
Priority: | Normal | ||
Assignee: | - | ||
Category: | Unknown | ||
Affected QGIS version: | 2.16.1 | Regression?: | No |
Operating System: | windows | Easy fix?: | No |
Pull Request or Patch supplied: | No | Resolution: | |
Crashes QGIS or corrupts data: | No | Copied to github as #: | 23429 |
Description
I'll describe this as steps:
- Create a SHAPE layer with 4 points on a line (so its easy to reference them by number).
- Delete the third point and stay in editing mode.
- Make the following python calls:
>>> req = QgsFeatureRequest()
>>> req = req.setLimit(3)
>>> len(list(iface.mapCanvas().currentLayer().getFeatures(req)))
2
I would expect the above getFeatures
request to return 3 features, since that should be the number of features left and at the same time within the limit defined by the request.
Based on a brief discussion on the mailing list, Nyall proposes the following:
I'd say something like this could work. In QgsVectorLayerFeatureIterator: - take the feature request limit for mProviderRequest - if deleted features are present in the edit buffer, add the number of deleted features to the limit in mProviderRequest - if changed feature attributes are present, and the request is an expression based request, add the number of changed features to the limit (could be smarter here and check which attributes are required by the filter + which have changed) - if geometry changes are present and a filter rect is in place then add the number of geometry changes to the limit That would still gain us most of the benefits of feature limits + handle this case, and the only penalty is present when the bug would otherwise show itself.
The bug is also present in master (d3882d5).
Associated revisions
Correctly handle edit buffer when using request with limit (fix #15505)
Correctly handle edit buffer when using request with limit (fix #15505)
(cherry-picked from 2665eb50a69220324f4a6d045e8eba6601760dd3)
Correctly handle edit buffer when using request with limit (fix #15505)
(cherry-picked from 2665eb50a69220324f4a6d045e8eba6601760dd3)
History
#1 Updated by Nyall Dawson about 8 years ago
- Status changed from Open to Closed
Fixed in changeset 2665eb50a69220324f4a6d045e8eba6601760dd3.
#2 Updated by Jürgen Fischer over 7 years ago
- Category set to Unknown