From 87e0d10d337f263f6ae0af156f60531328d52a39 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 16 Mar 2024 14:47:03 +0100 Subject: [PATCH] Sketch: fixes #12480: Sketcher_CreateBSplineByInterpolation Unhandled unknown C++ exception The interpolation of a BSpline can fail and then OCC throws an exception. Because this OCC exception isn't handled by the DrawSketchHandler the core system handles it as unknwon C++ exception --- .../Gui/DrawSketchHandlerBSplineByInterpolation.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerBSplineByInterpolation.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerBSplineByInterpolation.h index 3880a0c741..14b73d03bb 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerBSplineByInterpolation.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerBSplineByInterpolation.h @@ -416,11 +416,25 @@ private: } void drawBSplineToPosition(Base::Vector2d position) + { + try { + tryInterpolateSpline(position); + } + catch (const Standard_Failure&) { + // Since it happens very frequently that the interpolation fails + // it's sufficient to report this as log message to avoid to pollute + // the output window + Base::Console().Log(std::string("drawBSplineToPosition"), "interpolation failed\n"); + } + } + + void tryInterpolateSpline(Base::Vector2d position) { std::vector editcurve(BSplineKnots); editcurve.push_back(position); std::vector editCurveForOCCT; + editCurveForOCCT.reserve(editcurve.size()); for (auto& p : editcurve) { editCurveForOCCT.emplace_back(p.x, p.y, 0.0); }