Added sink commitment following qgis-pull-request #59241#333
Added sink commitment following qgis-pull-request #59241#333jannefleischer wants to merge 2 commits intoGIScience:mainfrom
Conversation
koebi
left a comment
There was a problem hiding this comment.
Hey,
in general, I'm all for cleaning up.
In this case, however, it seems like this doesn't do the right thing, at least not in the current implementation?
|
|
||
| feedback.setProgress(int(100.0 / count * num)) | ||
|
|
||
| sink.flushBuffer() |
There was a problem hiding this comment.
According to the linked PR, we should check the return value and notify the user.
There was a problem hiding this comment.
I think for whatever reason this should work, but doesn't work in all versions:
https://github.com/qgis/QGIS/pull/59241/files (so finalize was added)
https://github.com/qgis/QGIS/blob/master/src/core/processing/qgsprocessingutils.h#L811 - from 3.42 onwards this seems to be mandatory.
| if hasattr(sink, "finalize"): | ||
| sink.finalize() |
There was a problem hiding this comment.
Are there sinks that have a finalize method? I couldn't find any.
There was a problem hiding this comment.
The finalize() method was added in the linked PR (Nov 12, 2024), so every version after that should have the finalize method (3.42, I think).
| else: | ||
| del sink |
There was a problem hiding this comment.
Why does the sink get deleted?
There was a problem hiding this comment.
Some versions before the linked PR this was a workaround so that all data is really written down to file. This triggers the write process. Will be obsolete on newer versions.
I had trouble with long running tasks. At some point feature would be added to sink, but didn't manage to arrive at the returned layer. So something in the flush of the sink went wrong. I can't really tell why and how, but this seems to fix it.
Following QGIS-Pull-Request qgis/QGIS#59241