From 7c4131c4efb14ea098d3b2771fac49458bf6531d Mon Sep 17 00:00:00 2001 From: tetektoza Date: Sun, 24 Aug 2025 20:46:41 +0200 Subject: [PATCH] Sketcher: Disable autoscale if new constraint value is below precision As the title says - we can get into a scenario where user can specify constraint equal to 0.0, or similar small value and the scale factor will become 0 as well, resulting in all geometry trying to be rescaled to degenerate geometry. So this patch filters those values out, and bails out from auto-scaling leaving only solver to handle this value. --- src/Mod/Sketcher/Gui/DrawSketchHandlerScale.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerScale.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerScale.h index 52745dea3b..96e0a43e9f 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerScale.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerScale.h @@ -102,6 +102,14 @@ public: public: void executeCommands() override { + // validate scale factor to prevent geometric collapse and crashes + if (scaleFactor <= Precision::Confusion() || !std::isfinite(scaleFactor)) { + THROWM( + Base::ValueError, + QT_TRANSLATE_NOOP("Notifications", + "Invalid scale factor. Scale factor must be a positive number.")); + } + try { Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Scale geometries"));