-
-
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
main annotation layer should be used as a valid option even if type hint is set to UnknownType (fix #49010) #60341
base: master
Are you sure you want to change the base?
Conversation
is set to UnknownType (fix qgis#49010)
🪟 Windows buildsDownload Windows builds of this PR for testing. 🪟 Windows Qt6 buildsDownload Windows Qt6 builds of this PR for testing. |
@@ -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 ) |
There was a problem hiding this comment.
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"?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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 returntrue
only if type hint is explicitly set toAnnotation
. In case of multiple layers input we check parameter value using theUnknownType
type hint and main annotation layer won't be considered as a valid parameter value.Fixes #49010.