From 1683f271c643482293f1fa86382e3eb41db5d280 Mon Sep 17 00:00:00 2001 From: tetektoza Date: Wed, 22 Oct 2025 14:21:40 +0200 Subject: [PATCH] Import: Fix crash in glTF importer when removeSplitter() fails Currently `removeSplitter()` function attempts to merge coplanar faces by using `ModelRefine::FaceUniter`, which internally uses `BRepBuilderAPI_Sewing`. This can fail in several scenarios, like inability to produce a valid shell, failing in face unification due to geometry incompatibilities, or when we have tolerance issue in the reconstructed geometry from glTF triangulation that prevent us from face merging. That leads to the exception, which we are not handling correctly where it's being handled the same way as this patch introduces in other parts of FreeCAD. So, this patch adds a try-catch block around `removeSplitter()` to gracefully handle `Standard_Failure` exception and return the sewn shape instead of crashing. Imported model will contain more individual faces than necessary (since coplanar won't be merged), resulting in a more complex topology in the places of those fails, but geometry and visual appearance will be preserved. --- src/Mod/Import/App/ReaderGltf.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Mod/Import/App/ReaderGltf.cpp b/src/Mod/Import/App/ReaderGltf.cpp index 478e161af0..12b60a0a15 100644 --- a/src/Mod/Import/App/ReaderGltf.cpp +++ b/src/Mod/Import/App/ReaderGltf.cpp @@ -153,7 +153,12 @@ TopoDS_Shape ReaderGltf::fixShape(TopoDS_Shape shape) // NOLINT if (cleanup()) { sh.sewShape(); - return sh.removeSplitter(); + try { + return sh.removeSplitter(); + } + catch (const Standard_Failure& e) { + return sh.getShape(); + } } return sh.getShape();