Bug report #14390
Layer id generation prone to collisisions and overwrite in asynchronous layer creation
|Affected QGIS version:||2.12.0||Regression?:||No|
|Operating System:||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||22371|
In http://qgis.org/api/qgsmaplayer_8cpp_source.html#l00076 you can see the ID of a layer is generated by appending the current date to the layer name (with some minor verification applied). If several layers with the same name are created simultaneously, QGIS will assign them the same ID.
If they are later added to the map layer registry, only the last layer added to it will actually be in it, and will overwrite the previously 'stored' layer with that same ID.
I found this out while attempting to add similarly named layers to groups: checks failed when comparing the provided layer by it's id with the one stored in the map layer registry. The post (and what I found out, as the solution) is here:
The solution I propose is to append an UUID in the ID instead of the date, to avoid this issue.
#2 Updated by Giovanni Manghi over 3 years ago
- Crashes QGIS or corrupts data changed from Yes to No
- OS version deleted (
- Operating System deleted (
- Priority changed from High to Normal
- Status changed from Open to Feedback
Did anything changed in latest QGIS releases? Could you submit a patch?