From 5d76be01e138e0ed43aa69a4c2ca1bde9e65450d Mon Sep 17 00:00:00 2001 From: matthiasdanner Date: Fri, 12 Sep 2025 17:52:33 +0200 Subject: [PATCH] Sketcher: Fix Freeze in Offset with too large negative value (#23467) * Sketcher: Fix Freeze in Offset with too large negative value * Remove ErrorMessages when offsetting circles with too large negative value * fix linting comment * Add Error feedback --------- Co-authored-by: Matthias Danner <28687794+matthiasdanner@users.noreply.github.com> --- src/Mod/Sketcher/Gui/DrawSketchHandlerOffset.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerOffset.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerOffset.h index adb94aacd3..d197f74f9b 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerOffset.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerOffset.h @@ -259,7 +259,7 @@ private: TopoDS_Shape offsetShape = mkOffset.Shape(); if (offsetShape.IsNull()) { - throw Base::CADKernelError("makeOffset2D: result of offsetting is null!"); + return offsetShape; } // Copying shape to fix strange orientation behavior, OCC7.0.0. See bug #2699 @@ -344,6 +344,9 @@ private: std::vector& listOfOffsetGeoIds) { TopoDS_Shape offsetShape = makeOffsetShape(); + if (offsetShape.IsNull()) { + return; + } TopExp_Explorer expl(offsetShape, TopAbs_EDGE); int geoIdToAdd = firstCurveCreated; @@ -383,6 +386,15 @@ private: getOffsetGeos(geometriesToAdd, listOfOffsetGeoIds); SketchObject* Obj = sketchgui->getSketchObject(); + + if (listOfOffsetGeoIds.empty()) { + Gui::NotifyUserError( + Obj, + QT_TRANSLATE_NOOP("Notifications", "Offset Error"), + QT_TRANSLATE_NOOP("Notifications", "Offset could not be created.")); + return; + } + Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Offset")); // Create geos @@ -403,6 +415,9 @@ private: void jointOffsetCurves(std::vector& listOfOffsetGeoIds) { + if (listOfOffsetGeoIds.empty()) { + return; + } std::stringstream stream; stream << "conList = []\n"; for (size_t i = 0; i < listOfOffsetGeoIds.size() - 1; i++) {