From c3ec0b7c49cb505dc0195699a6e0be9b0e2f4e87 Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 5 Apr 2022 16:27:16 +0200 Subject: [PATCH] FEM: work around a crash with vtk9 on export of a vtkUnstructuredGrid --- src/Mod/Fem/App/PropertyPostDataObject.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Mod/Fem/App/PropertyPostDataObject.cpp b/src/Mod/Fem/App/PropertyPostDataObject.cpp index 1f57f41612..c4945d182b 100644 --- a/src/Mod/Fem/App/PropertyPostDataObject.cpp +++ b/src/Mod/Fem/App/PropertyPostDataObject.cpp @@ -264,6 +264,15 @@ void PropertyPostDataObject::SaveDocFile (Base::Writer &writer) const xmlWriter->SetFileName(fi.filePath().c_str()); xmlWriter->SetDataModeToBinary(); +#ifdef VTK_CELL_ARRAY_V2 + // Looks like an invalid data object that causes a crash with vtk9 + vtkUnstructuredGrid* dataGrid = vtkUnstructuredGrid::SafeDownCast(m_dataObject); + if (dataGrid && dataGrid->GetPiece() < 0) { + std::cerr << "PropertyPostDataObject::SaveDocFile: ignore broken vtkUnstructuredGrid\n"; + return; + } +#endif + if ( xmlWriter->Write() != 1 ) { // Note: Do NOT throw an exception here because if the tmp. file could // not be created we should not abort.