Skip to content

Commit

Permalink
FEM: work around a crash with vtk9 on export of a vtkUnstructuredGrid
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Apr 5, 2022
1 parent 670d092 commit c3ec0b7
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Mod/Fem/App/PropertyPostDataObject.cpp
Expand Up @@ -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.
Expand Down

0 comments on commit c3ec0b7

Please sign in to comment.