-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[processing] show warning when file-based layer could not be loaded #8967
Conversation
…nd dependent params updated For algorithms with multiple parameters depending on a vector layer parameter, the code that loads the layer in the background is called repeatedly, impacting performance. A small layer cache is implemented with these changes, so the dialog only tries to load the layer once.
@@ -1615,14 +1620,26 @@ def postInitialize(self, wrappers): | |||
break | |||
|
|||
def parentValueChanged(self, wrapper): | |||
self.setLayer(wrapper.parameterValue()) | |||
value = wrapper.parameterValue() | |||
if value in wrapper.fileBasedLayers: |
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.
What's this code for?
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.
If the loaded layer is in the cache, it sets the widget layer with it instead of the parameter value. Otherwise, it just calls set layer with value itself.
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.
It's not directly required by this PR though, is it? The QgsProcessingUtils.mapLayerFromString
call used in setLayer already effectively uses a cache inside self.context, so we end up double-caching here, at a cost of more code complexity.
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.
Not really required, but the performance improvement is noticeable. Otherwise, for an algorithm such as "Create point layer from table", with 4 dependent fields, mapLayerFromString is called 4 times, and the warning message is shown with a rather long delay.
I didnt know there was a cache in that method, but looks like it is not working in this case. Maybe mapLayerFromString is not caching when the layer cannot be read (wrong layer file, as in this case), and for this reason it tries 4 times to load the wrong layer (all of them unsuccessfully)
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.
Maybe mapLayerFromString is not caching when the layer cannot be read
Ah, you're right. All good here :)
Description
Show warning when file-based layer could not be loaded and dependent params updated
For algorithms with multiple parameters depending on a vector layer parameter, the code that loads the layer in the background is called repeatedly, impacting performance. A small layer cache is implemented with these changes, so the dialog only tries to load the layer once.
Checklist
fixes #11111
in the commit message next to the description[FEATURE]
in the commit message[needs-docs]
in the commit message and contain sufficient information in the commit message to be documentedscripts/prepare-commit.sh
script before each commit