From f3a8f711fd4e57b685470b514428c3b6ddc0e754 Mon Sep 17 00:00:00 2001 From: Kenneth Raplee <101818165+kenrap@users.noreply.github.com> Date: Mon, 28 Sep 2026 10:44:32 +0000 Subject: [PATCH] Catch Standard_Failure before std::exception (OCCT >= 8) (#15826) Co-authored-by: yw4z --- src/libslic3r/CAD/CadDocument.cpp | 4 ++-- src/slic3r/GUI/CAD/DesignPanel.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libslic3r/CAD/CadDocument.cpp b/src/libslic3r/CAD/CadDocument.cpp index c20b636ae7..ea20ffd966 100644 --- a/src/libslic3r/CAD/CadDocument.cpp +++ b/src/libslic3r/CAD/CadDocument.cpp @@ -2673,10 +2673,10 @@ void CadDocument::apply_feature(TopoDS_Shape& result, bool& have_body, ridge = pipe.Shape(); have_ridge = !ridge.IsNull(); } + } catch (const Standard_Failure&) { + have_ridge = false; // OCCT failure — on OCCT >= 8 Standard_Failure derives from std::exception, so this handler must come first } catch (const std::exception&) { have_ridge = false; // fall back to the bare cylinder/bore below - } catch (const Standard_Failure&) { - have_ridge = false; // OCCT failure (not a std::exception) — must be caught here too } if (f.thread_internal) { diff --git a/src/slic3r/GUI/CAD/DesignPanel.cpp b/src/slic3r/GUI/CAD/DesignPanel.cpp index 0b4f86a618..d247ddfd26 100644 --- a/src/slic3r/GUI/CAD/DesignPanel.cpp +++ b/src/slic3r/GUI/CAD/DesignPanel.cpp @@ -4862,13 +4862,13 @@ void DesignPanel::on_import_mesh() try { shape = GeometryEngine::mesh_to_brep(mesh.its, MESH_IMPORT_TOLERANCE, MESH_IMPORT_MERGE_ANGLE_DEG, stats); - } catch (const std::exception& e) { - fail(_L("Mesh conversion failed: ") + wxString::FromUTF8(e.what())); - return; - } catch (const Standard_Failure& e) { // OCCT throws outside std::exception + } catch (const Standard_Failure& e) { // on OCCT >= 8 Standard_Failure derives from std::exception — must precede that handler fail(_L("Mesh conversion failed: ") + wxString::FromUTF8( e.GetMessageString() ? e.GetMessageString() : "OCCT error")); return; + } catch (const std::exception& e) { + fail(_L("Mesh conversion failed: ") + wxString::FromUTF8(e.what())); + return; } if (shape.IsNull()) { fail(_L("Mesh conversion produced no geometry")); return; }