Skip to content
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

When duplicating a layer copy layer tree layer's custom properties [fixes #60884] #60897

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Alex-Kent
Copy link

Description

When using Duplicate Layer in the Layers panel only the custom properties for the QgsMapLayer were being copied with any custom properties for the associated QgsLayerTreeLayer being omitted.

This PR fixes that issue by copying the source layer tree layer's custom properties to the new layer tree layer.

I've tested the code and it behaves as expected. Test cases included those described in the bug report as well as with the Layer Color Plugin (which is affected by this bug).

Backporting this fix to the LTR releases would be nice.

Fixes #60884

@github-actions github-actions bot added this to the 3.44.0 milestone Mar 7, 2025
Copy link
Contributor

@signedav signedav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch. Code looks good. Did you check if any custom property used from QGIS itself might make no sense to be duplicated? Just to be sure.

@Alex-Kent
Copy link
Author

Alex-Kent commented Mar 8, 2025

Did you check if any custom property used from QGIS itself might make no sense to be duplicated?

There is a list of some custom properties used by QGIS with QgsLayerTreeNode (the base class for both QgsLayerTreeLayer and QgsLayerTreeGroup) in the class' documentation; there does not appear to be a similar list for QgsMapLayer. I can't say whether the list on that page is definitive/complete. Regarding your query, all of the custom properties listed in the class documentation seem sensible to duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Duplicate Layer" does not copy some custom properties
2 participants