Bug report #19489

Saving with a "Duplicate Layer" overwrites the original source files without asking !!!

Added by Loren Amelang over 6 years ago. Updated over 6 years ago.

Status:Closed
Priority:High
Assignee:-
Category:Project Loading/Saving
Affected QGIS version:3.2 Regression?:No
Operating System:Windows 10 Creators with 3000x2000 screen and 175% scaling Easy fix?:No
Pull Request or Patch supplied:No Resolution:invalid
Crashes QGIS or corrupts data:Yes Copied to github as #:27317

Description

My 600 hand-edited features are now gone. I made a "Duplicate Layer" to perform my (click table line, shift-click another table line, Edit mode, trash icon) deletions in, but judging from the results on disk, the selections and deletions were applied to the original layer, and a second layer was not saved.

I don't remember it asking me for a new file name... The Duplicate must have overwritten the original files. This is way too dangerous for real users!

I worked with the duplicate layer successfully, as far as I could tell. But when I went back to the original layer to create a new selection, it had decided the remaining items that were not deleted from the duplicate layer (that were then saved into the original filename) were "Filtered" in the original layer. I had never intentionally used a filter.

Up until I quit QGIS, the original layer showed all 608 features, both in the "Show feature count" label and in the header of the Attribute Table. Only the few it had decided were Filtered (the ones I had not deleted from the duplicate layer) would show in the table, and "Show all Features" refused to show the rest.

I searched all over the web for clues, but couldn't find any way to show the other 600 features. Apparently they were already gone, despite the obvious counts.

The counts were a problem earlier in the day on a related layer - see "XSCutLines imported from Transect by RiverGIS - count 0.JPG". Despite there obviously being 608 items in the table, the count in the Layers panel insisted on zero. Probably a different issue.

I've been wishing there was a config option to always "Show feature count" in the Layers panel. But if it is this misleading, maybe not...

Searching before posting this, I see #13782
Deleting columns in duplicate layer also deletes them in original layer
Where a similar issue was declared invalid: "'duplicate layer' do not duplicate (create a copy of) the datasource, it just duplicates in the project, the layer is the same."

I strongly disagree! QGIS in this scenario deletes user data with no warning, and the user interface actually misleads the user into believing the data is still there! Until the project is closed and re-opened, when the sad truth is unavoidable.

Obviously edits within a session affect the original and duplicate layers independently. If Duplicate Layer is intended to not create its own datasource, then changes to it should not be saved. It would be nice if you asked us if we want them saved... But they absolutely should not be saved to the original datasource files with no warning!

XSCutLines imported from Transect by RiverGIS - count 0.JPG - "Show feature count" = 0 despite obvious features (87.1 KB) Loren Amelang, 2018-07-25 09:40 PM

Associated revisions

Revision f14ae460
Added by Jürgen Fischer over 6 years ago

add note that duplicated layers use the same data source (fixes #19489)

History

#1 Updated by Giovanni Manghi over 6 years ago

  • Status changed from Open to Closed
  • Resolution set to invalid

"Duplicate layer" does not means you are making a copy of a layer, it means you are duplicating it in the context of your project, the datasource remains the same, so if you are editing the "duplicated" one, you are effectively editing also the "original" one. This is an intended behavior.

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

  • Description updated (diff)

#3 Updated by Loren Amelang over 6 years ago

  • Status changed from Closed to Reopened

Okay, if that is the intention, I guess I have to accept it.

But "if you are editing the 'duplicated' one, you are effectively editing also the 'original' one", then all of the indicators for the original layer should change along with the duplicate indicators. In my case, up until I quit QGIS, the original layer showed all 608 features, both in the "Show feature count" label and in the header of the Attribute Table.

If the original layer had shown my deletions immediately, I'd have figured out the layers remained linked, while there was still time to go make a Windows copy of my datasource files. Instead QGIS showed me my 608 features were all in the original, albeit "filtered". Which wasted another hour of my time trying to un-filter them...

Do I need to file this misleading indicator issue as a separate report?

Whatever is the purpose of having a Duplicate Layer if everything you do to it also happens to the original?

And if they are two independent layers "in the context of your project", why is only one considered worth saving? And most importantly, why is it the newly duplicated version which is saved, destroying the original datasource? I would expect the duplicate to be considered the temporary version, and the original datasource to be preserved. (A user-friendly program would then ask if we wanted to save the duplicate layer...)

I don't mean to seem arrogant, I'm just trying to prevent other users from losing hours of their lives to a QGIS behavior that seems quite illogical to me.

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

  • Status changed from Reopened to Closed
  • % Done changed from 0 to 100

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

Loren Amelang wrote:

But "if you are editing the 'duplicated' one, you are effectively editing also the 'original' one", then all of the indicators for the original layer should change along with the duplicate indicators. In my case, up until I quit QGIS, the original layer showed all 608 features, both in the "Show feature count" label and in the header of the Attribute Table.

There's no explicit link. Duplication of the layer simply re-adds the same data source with the same settings - just like if you had added the same data source again and had copied the style manually - in which case updates via other layers (or external changes) will also not be reflected.

Whatever is the purpose of having a Duplicate Layer if everything you do to it also happens to the original?

E.g. showing the same data with different styling or showing a layer that you're editing in it's original state.

#6 Updated by Loren Amelang over 6 years ago

@Jürgen Fischer,

Thank you! At least the message bar will provide some warning that the user might need to consider future actions.

Looking at https://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/communicating.html?highlight=message%20bar, I'm not clear if you intended a timer or not:

You can set a duration to show it for a limited time

iface.messageBar().pushMessage("Error", "Ooops, the plugin is not working as it should", level=Qgis.Critical, duration=3)

I'm guessing that docs page is out of date? Does

Qgis::Info, messageTimeout()

mean no timeout (I hope)? Or is there a default for an empty parameter?

BTW, is it better not to use the "Link to a wiki page" button for links? I notice you change them when I link to bug reports. Or maybe this time I should have used it?

Also available in: Atom PDF