Bug report #8822
OGR: Repack in running session
Status: | Closed | ||
---|---|---|---|
Priority: | High | ||
Assignee: | - | ||
Category: | Data Provider/OGR | ||
Affected QGIS version: | 2.0.1 | Regression?: | No |
Operating System: | Easy fix?: | No | |
Pull Request or Patch supplied: | No | Resolution: | |
Crashes QGIS or corrupts data: | No | Copied to github as #: | 17515 |
Description
OGR does not delete features in shapefiles immediately. Instead, it marks and skips features when they are being deleted, until the REPACK command is issued which then really deletes them. This command also assigns new feature ids to the features.
Currently REPACK is called, whenever a spatial index is created on a shapefile. When a feature is being deleted, createSpatialIndex() is called in order to issue REPACK.
This can happen at any time the layer is opened and can lead to undesiered effects. E.g. open an attribute table of a layer, delete features with low feature ids and save the edits. The attribute table will show ERROR instead of the attribute values, because the feature ids have silently changed.
I would propose to ONLY call REPACK, when closing a layer. Attention has to be paid if indexes need to be rebuilt or if OGR does this automatically.
Related issues
Associated revisions
[ogr] Only call repack when closing a data provider
Fix #8822
[ogr] Only call repack when closing a data provider
Fix #8822
Repack shapefiles when saving after deleting features
- QgsVectorDataProvider::dataChanged() will be emitted
- QgsVectorLayer::dataChanged() will be emitted
- Clears QgsVectorLayerCache
- Reloads the attribute table
- Clears the selection
Looking forward to people complaining about their lost selection...
Fix #10560
Fix #11989
Refs #8317
Refs #8822
Refs #10483
Refs #11007
Refs #7540
Refs #11398
Refs #11296
History
#1 Updated by Matthias Kuhn almost 11 years ago
I suspect the following report is connected to this bug:
http://gis.stackexchange.com/questions/58101/how-to-avoid-creating-corrupt-shapefiles-during-editing
Looking at the OGR sourcecode, .shx files are rewritten as well, so the index should be ok I think.
If there is no objection, I am going to implement this.
#2 Updated by Matthias Kuhn almost 11 years ago
- Status changed from Open to Closed
Fixed in changeset ba76c99037d84fb0fbc7d3eea7a3a6bcc5f69148.
#3 Updated by Giovanni Manghi about 10 years ago
Hi Matthias,
would you mind have a look at
I don't know if the issue described there is related to ogr repack, but anyway seems pretty severe (even if not strictly a regression) as is causes a major interoperability issue.
Thanks in advance.