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

[Masking] Fix copy/paste of symbol or converting renderer #60325

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

Conversation

troopa81
Copy link
Contributor

Properly reset symbol layer ids when copy/pasting symbol or when converting a rule based renderer into a categorized renderer.

Fixes #46402 where issues comes from symbol layers having identical symbol layers ids, coming from I presume, actions described just above

@github-actions github-actions bot added this to the 3.42.0 milestone Jan 28, 2025
@troopa81 troopa81 changed the title Fix smask copypaste [Masking] Fix copy/paste of symbol or converting renderer Jan 28, 2025
Copy link

github-actions bot commented Jan 28, 2025

🪟 Windows builds

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

🪟 Windows Qt6 builds

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

{
if ( QgsSymbolLayer *sl = symbol->symbolLayer( idx ) )
{
sl->clearMasks();
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd lean toward a dynamic_cast to QgsMaskMarkerSymbolLayer here and then directly calling QgsMaskMarkerSymbolLayer::clearMasks to avoid the virtual clearMasks method in QgsSymbolLayer.

If later on we find other symbol layer types which need this handled then we can safely resurrect the virtual method without any API breakage.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I considered this solution but preferred to have clearMasks() method for 2 reasons:

  • to be consistent with masks() method (this is not the case of setMasks() but maybe this one should also be defined as a virtual method of QgsSymbolLayer)
  • dynamic_cast is a bad design and should be avoided

Even if we never get a symbol layer types implementing masks, why do you think it is better with dynamic_cast ?

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.

Masking labels doesn't work with rule based labeling
2 participants