-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Duplicate Layer" does not copy some custom properties #60884
Comments
I've found the calls that handle this (and a potential fix, see the end of the comment). For copy/paste (correct behavior):In method Line 10369 in 9a1d453
In method Line 10405 in 9a1d453
For duplicate layer (incorrect behavior):In method For Vector layers: Line 11709 in 9a1d453
For PointCloud, Raster, VectorTile, Mesh, Annotation, and TiledScene layers: Line 11721 in 9a1d453
The actual code that copies the custom properties appears to be: In method Line 160 in 9a1d453
However this only copies the properties for the After the Lines 11766 to 11779 in 9a1d453
Perhaps the custom properties for the new // duplicate the layer tree layer's custom properties
for ( const QString &key : nodeSelectedLyr->customProperties() )
{
nodeDupLayer->setCustomProperty(key, nodeSelectedLyr->customProperty(key));
} [The above code has not been tested.] Thoughts? |
What is the bug or the crash?
Observed behavior
When "Duplicate Layer" is used any custom properties set for the original layer via the layer tree interface are not copied to the new layer.
Expected behavior
All custom properties set for the original layer should also be set in the duplicate layer.
Additional notes
If "Copy Layer" or "Copy Group" followed by "Paste Layer/Group" is used then all custom properties are preserved in the new layers/groups.
It appears that there are two sets of custom properties for each layer/group: those set via the layer tree (in
QgsProject.instance().layerTreeRoot()
) and those set via the set of map layers (inQgsProject.instance().mapLayers()
). For copy/paste custom properties for both are carried over; for duplicate only those in the latter are.Steps to reproduce the issue
ShowValues()
[The specific layer IDs shown will be different from those in this example.]
ShowValues()
All custom properties are present in the copied layer (this is the expected behavior).
Delete the newly-created layer (the second layer in the Layers list)
Duplicate the original layer:
ShowValues()
Only the value set via the map layers interface is present in the duplicate layer.
The value set via the layer tree interface is not present in the duplicate layer (but it should be present).
Versions
This version of QGIS is the latest version for this [actively-supported] Ubuntu LTS release.
Edit: I also built QGIS from source, behavior is the same.
Supported QGIS version
New profile
Additional context
I encountered this while working on improvements to the Layer Color Plugin. That plugin uses custom properties (via the layer tree interface) to store layer colors.
The text was updated successfully, but these errors were encountered: