Changing vtkAlgorithm::Update() return type from `void` to `bool`

Fixed in VTK master, but you will need to update your code to override the new method, WriteDataAndReturn in your own custom writers.

The MRE I gave above:

import vtk

polydata = vtk.vtkPolyData()
writer = vtk.vtkXMLPolyDataWriter()
writer.SetFileName("does_not_exist/empty.vtp")
writer.SetInputData(polydata)
status = writer.Write()
print(status)

Still returns 1 with the latest dev wheels (9.6.20260228.dev0), indicating success. But I still would expect 0 returned. So maybe this hasn’t been fixed after all? Or am I missing something?

Indeed, here is the fix: https://gitlab.kitware.com/vtk/vtk/-/merge_requests/12978

Now fixed :slight_smile:

1 Like

In your fix, you changed vtkXMLWriterBase::Write():

-  this->Update();
-  return 1;
+  return this->Update() ? 1 : 0;

Now that vtkAlgorithm::Update() returns bool, are there other methods in VTK that still follow the old pattern of “call Update(), then return constant success”? If so, callers who use those wrappers would still see “success” even when the pipeline failed (like user27182’s bug report).

Is there a way to audit for remaining instances (e.g., searching for Update(); near return 1; or return true;) or maybe a clang-based search?

Here are the one I found with the Update pattern:
https://gitlab.kitware.com/vtk/vtk/-/merge_requests/12983

But there could be more definitely, writer users will have to test/report/fix individually.