Bug report #7540

Merge tool bug when a shapefile is loaded multiple times

Added by Olivier Dalang over 6 years ago. Updated almost 5 years ago.

Status:Closed
Priority:Severe/Regression
Assignee:-
Category:Digitising
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:fixed/implemented
Crashes QGIS or corrupts data:Yes Copied to github as #:16483

Description

Hi !

When a Shapefile is loaded multiple times (either in the same project via "duplicate layer" or in two different QGis instances), there is a critical bug upon merging features.

Both merged parts simply disappear without any error (though it seems sometimes QGis crashes).

To reproduce:
  1. create a new shapefile (line or polygon)
  2. enter edit mode
  3. draw a feature and split it several times with the scissor tool
  4. exit edit mode
  5. duplicate the layer
  6. enter edit mode on one of the two layers
  7. select two line segments and merge them with the merge tool
  8. exit edit mode
  9. reload the project and see!!

Related issues

Related to QGIS Application - Bug report #8822: OGR: Repack in running session Closed 2013-10-11

Associated revisions

Revision 78b04df9
Added by Jürgen Fischer over 6 years ago

ogr provider: reopen the data source if a REPACK failed (fixes #7540)

Revision 7d7cdcd3
Added by Matthias Kuhn over 4 years ago

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 Giovanni Manghi over 6 years ago

  • Status changed from Open to Feedback

it is a regression since 1.8? I'm not able to replicate the issue here, but maybe I'm doing it wrong.

#2 Updated by Olivier Dalang over 6 years ago

Yes it's a regression, the problem does not show up in 1.8...

Here (Windows 7) it seems to happen every time when following those steps.

If confirmed, this should be a blocker, since it leads to data corruption.

#3 Updated by Giovanni Manghi over 6 years ago

  • Priority changed from Normal to Severe/Regression

#4 Updated by Radim Blazek over 6 years ago

9) reload the project and see !!

What does it mean "reload the project"? Reopen project file or refresh display?

#5 Updated by Olivier Dalang over 6 years ago

Actually, when you refresh display only :
  • on the layer that was not edited, you see that the two merged parts have disappeared
  • on the layer that was edited, you see the two merged parts plus the result of the merge

But actually, I'm just discovering that the shapefile seems in a deeper mess, even after reloading : if you create a new polygon, no matter what shape, it will take the shape of the result of the merge.

Here's a screencast of the procedure :
https://www.dropbox.com/s/84nj515s6mfu09f/mergeBug2.avi?m

#6 Updated by Giovanni Manghi over 6 years ago

  • Status changed from Feedback to Open

#7 Updated by Giovanni Manghi over 6 years ago

  • Category set to Digitising

#8 Updated by Salvatore Larosa over 6 years ago

is it still true ?

following the above steps I did not get any crash !
tested with a polygon layer and I do not see unusual behavior.

#9 Updated by Giovanni Manghi over 6 years ago

following the above steps I did not get any crash !
tested with a polygon layer and I do not see unusual behavior.

I don't think it causes crash, it causes data corruption.

#10 Updated by Jürgen Fischer over 6 years ago

  • Status changed from Open to Feedback

Giovanni Manghi wrote:

I don't think it causes crash, it causes data corruption.

So you can reproduce the problem? Just checking, if I should try harder...

#11 Updated by Giovanni Manghi over 6 years ago

So you can reproduce the problem? Just checking, if I should try harder...

no I can't.

Olivier still true for you?

#12 Updated by Olivier Dalang over 6 years ago

Hi !

The behavior changed a little bit but I still get data corruption (with master from yesterday, under Windows 7).
It's no more necessary to reload the project to see the data loss.

Here's a screencast : https://www.dropbox.com/s/g70fkaus6j40vll/mergeBug4.avi

#13 Updated by Jürgen Fischer over 6 years ago

  • Status changed from Feedback to Open

ok, I can reproduce it now. I suspect it's a file locking issue in OGR (might be tied to windows). Looking into GDAL now...

#14 Updated by Jürgen Fischer over 6 years ago

  • Assignee set to Jürgen Fischer

#15 Updated by Jürgen Fischer over 6 years ago

  • Status changed from Open to Closed

#16 Updated by Jürgen Fischer over 6 years ago

Jürgen Fischer wrote:

Fixed in changeset 78b04df91a1b85ee70ff5b326980f480b3069d47.

It was caused by locking. QGIS does a REPACK after deleting and that silently fails with current OGR. GDAL pull request #17 should fix this by adding an error message. reopening the original DBF if it can't be removed and cleaning up the *_packed.dbf.

Nevertheless QGIS now checks if there still is a *_packed.dbf to detect that the REPACK failed and reopens the dataset in that case.

#17 Updated by Giovanni Manghi about 5 years ago

  • Status changed from Closed to Reopened
  • Target version changed from Version 2.0.0 to Version 2.6

Sorry to reopen this, seems master still affected. See also #11082

#18 Updated by Jürgen Fischer almost 5 years ago

  • Assignee deleted (Jürgen Fischer)

#19 Updated by Giovanni Manghi almost 5 years ago

it is pretty easy to replicate this issue, it is just needed to "insist" a bit. Here two screencast, that as some point show that after removing a shape and re-adding it features are lost!

The second show also a possible bug in the "split features" tool.

https://www.dropbox.com/s/rpjcn8gpn75r31m/t7540_1.mp4?dl=0

https://www.dropbox.com/s/9n9a7j1puugwpnr/t7540_2.mp4?dl=0

#20 Updated by Giovanni Manghi almost 5 years ago

Giovanni Manghi wrote:

Sorry to reopen this, seems master still affected. See also #11082

after all it does not seems related... I have a VM with qgis running against gdal/ogr trunk and I can still see the issue described in this ticket.

#21 Updated by Giovanni Manghi almost 5 years ago

  • Status changed from Reopened to Feedback

it seems this could have been solved by this 4cf08c5c112278ab4f50cf21b735a4a58d6a98aa

#22 Updated by Jürgen Fischer almost 5 years ago

  • Target version changed from Version 2.6 to Future Release - High Priority

#23 Updated by Giovanni Manghi almost 5 years ago

  • Status changed from Feedback to Closed
  • Resolution set to fixed/implemented

after 4cf08c5c112278ab4f50cf21b735a4a58d6a98aa I really cannot make to replicate this issue. That commit solves also partially #11007 (but only for the case of edited features, still there is an issue with deleted ones).

Please reopen if necessary.

Also available in: Atom PDF