Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ORStools/proc/directions_lines_proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,12 @@ def processAlgorithm(

feedback.setProgress(int(100.0 / count * num))

sink.flushBuffer()
Copy link
Collaborator

Choose a reason for hiding this comment

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

According to the linked PR, we should check the return value and notify the user.

Copy link
Contributor Author

@jannefleischer jannefleischer Jul 1, 2025

Choose a reason for hiding this comment

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

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()
Comment on lines +256 to +257
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are there sinks that have a finalize method? I couldn't find any.

Copy link
Contributor Author

@jannefleischer jannefleischer Jul 1, 2025

Choose a reason for hiding this comment

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

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
Comment on lines +258 to +259
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why does the sink get deleted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.


return {self.OUT: dest_id}

@staticmethod
Expand Down
6 changes: 6 additions & 0 deletions ORStools/proc/directions_points_layer_proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,12 @@ def sort(f):

feedback.setProgress(int(100.0 / count * num))

sink.flushBuffer()
if hasattr(sink, "finalize"):
sink.finalize()
else:
del sink

return {self.OUT: dest_id}

def displayName(self) -> str:
Expand Down
6 changes: 6 additions & 0 deletions ORStools/proc/directions_points_layers_proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,12 @@ def sort_end(f):
counter += 1
feedback.setProgress(int(100.0 / route_count * counter))

sink.flushBuffer()
if hasattr(sink, "finalize"):
sink.finalize()
else:
del sink

return {self.OUT: dest_id}

@staticmethod
Expand Down
11 changes: 11 additions & 0 deletions ORStools/proc/export_proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,17 @@ def processAlgorithm(
feedback.reportError(msg)
logger.log(msg)

sink_line.flushBuffer()
if hasattr(sink_line, "finalize"):
sink_line.finalize()
else:
del sink_line

sink_point.flushBuffer()
if hasattr(sink_point, "finalize"):
sink_point.finalize()
else:
del sink_point
return {self.OUT: dest_id_line, self.OUT_POINT: dest_id_point}

@staticmethod
Expand Down
6 changes: 6 additions & 0 deletions ORStools/proc/isochrones_layer_proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,12 @@ def processAlgorithm(
continue
feedback.setProgress(int(100.0 / source.featureCount() * num))

sink.flushBuffer()
if hasattr(sink, "finalize"):
sink.finalize()
else:
del sink

return {self.OUT: self.dest_id}

# noinspection PyUnusedLocal
Expand Down
6 changes: 6 additions & 0 deletions ORStools/proc/isochrones_point_proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ def processAlgorithm(
feedback.reportError(msg)
logger.log(msg, 2)

sink.flushBuffer()
if hasattr(sink, "finalize"):
sink.finalize()
else:
del sink

return {self.OUT: self.dest_id}

# noinspection PyUnusedLocal
Expand Down
6 changes: 6 additions & 0 deletions ORStools/proc/matrix_proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,12 @@ def processAlgorithm(

sink.addFeature(feat)

sink.flushBuffer()
if hasattr(sink, "finalize"):
sink.finalize()
else:
del sink

return {self.OUT: dest_id}

# TODO working source_type and destination_type differ in both name and type from get_fields in directions_core.
Expand Down
6 changes: 6 additions & 0 deletions ORStools/proc/snap_layer_proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ def processAlgorithm(
feedback.reportError(msg)
logger.log(msg)

sink.flushBuffer()
if hasattr(sink, "finalize"):
sink.finalize()
else:
del sink

return {self.OUT: dest_id}

def displayName(self) -> str:
Expand Down
6 changes: 6 additions & 0 deletions ORStools/proc/snap_point_proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ def processAlgorithm(
feedback.reportError(msg)
logger.log(msg)

sink.flushBuffer()
if hasattr(sink, "finalize"):
sink.finalize()
else:
del sink

return {self.OUT: dest_id}

def displayName(self) -> str:
Expand Down
Loading