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

main annotation layer should be used as a valid option even if type hint is set to UnknownType (fix #49010) #60341

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

Conversation

alexbruy
Copy link
Contributor

Description

If Processing algorithm uses multiple layers parameter with Qgis::ProcessingSourceType::MapLayer type, annotation layers are should be considered as a valid choice. However, this will fail with the main annotation layer which exists in all projects by default.

The mapLayerFromString() method will return true only if type hint is explicitly set to Annotation. In case of multiple layers input we check parameter value using the UnknownType type hint and main annotation layer won't be considered as a valid parameter value.

Fixes #49010.

@alexbruy alexbruy added Processing Relating to QGIS Processing framework or individual Processing algorithms backport release-3_40 labels Jan 29, 2025
@alexbruy alexbruy requested a review from nyalldawson January 29, 2025 12:26
@github-actions github-actions bot added this to the 3.42.0 milestone Jan 29, 2025
Copy link

github-actions bot commented Jan 29, 2025

🪟 Windows builds

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

🪟 Windows Qt6 builds

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

@@ -516,7 +516,7 @@ QgsMapLayer *QgsProcessingUtils::mapLayerFromString( const QString &string, QgsP
return nullptr;

// prefer project layers
if ( context.project() && typeHint == LayerHint::Annotation && string.compare( QLatin1String( "main" ), Qt::CaseInsensitive ) == 0 )
if ( context.project() && ( typeHint == LayerHint::Annotation || typeHint == LayerHint::UnknownType ) && string.compare( QLatin1String( "main" ), Qt::CaseInsensitive ) == 0 )
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wouldn't this break things if the project eg contains a vector layer called "main"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it will break in that case and not only with vector layer but also with other layer types. We probably need to find another way to check validity of main annotation layer here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok -- how about splitting this logic then, and leaving the condition where the typeHint is set where it is (ie it gets first preference), and then adding the new logic where typeHint isn't set to just before the "if ( !allowLoadingNewLayers )" check?

That way the named project layer will still get preference when typeHint isn't set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport release-3_40 Processing Relating to QGIS Processing framework or individual Processing algorithms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Export Layer(s) Information processing tool suggests unsupported Annotations layer as input
2 participants