vtkUnstructuredGrid::ShallowCopy could fail for vtkUnstructuredGridBase sources
We encountered a bug with algorithms which output vtkUnstructuredGrid
if the input is vtkMappedUnstructuredGrid
.
At some point during pipeline execution the executive calls vtkUnstructuredGrid::Initialize
when it prepares the algorithm output. This deletes the connectivity and types arrays. However, algorithms (e.g. vtkArrayRename
) may then call vtkUnstructuredGrid::ShallowCopy
in RequestData. This is a problem because there is special handling for vtkUnstructuredGridBase
and the connectivity and type arrays are not recreated before a call to vtkUnstructuredGrid::InternalInsertNextCell
, resulting in a crash.
For example this will crash:
// vtkUnstructuredGridBase subclass other than vtkUnstructuredGrid, e.g. vtkMappedUnstructuredGrid
vtkSmartPointer<MyMappedGrid> source = ...;
vtkNew<vtkUnstructuredGrid> ug;
ug->Initialize(); // This deletes connectivity and type arrays
ug->ShallowCopy(source); // Crashes cause this accesses connectivity and type arrays
vtkUnstructuredGrid::ShallowCopy
needs to do an allocation if necessary in this case.