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

Merged
merged 2 commits into from
Mar 11, 2025

Conversation

Alex-Kent
Copy link
Contributor

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
Contributor 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. [edit: see my PR #60904] Regarding your query, all of the custom properties listed in the class documentation seem sensible to duplicate.

@Alex-Kent
Copy link
Contributor Author

@signedav I checked the QGIS source for all places where custom properties are being applied to QgsLayerTreeNode objects (see PR #60904). I saw none that would cause issues if duplicated. In other words, my code is safe in that regard.

Copy link

github-actions bot commented Mar 10, 2025

🪟 Windows Qt6 builds

Download Windows Qt6 builds of this PR for testing.
(Built from commit a5ebb3a)

🪟 Windows builds

Download Windows builds of this PR for testing.
Debug symbols for this build are available here.
(Built from commit a5ebb3a)

@signedav
Copy link
Contributor

@signedav I checked the QGIS source for all places where custom properties are being applied to QgsLayerTreeNode objects (see PR #60904). I saw none that would cause issues if duplicated. In other words, my code is safe in that regard.

Great. Thanks for the clearifications.

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

Successfully merging this pull request may close these issues.

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