diff --git a/src/Mod/Sketcher/Gui/DrawSketchController.h b/src/Mod/Sketcher/Gui/DrawSketchController.h
index 819e8ebf0e..7f0347953d 100644
--- a/src/Mod/Sketcher/Gui/DrawSketchController.h
+++ b/src/Mod/Sketcher/Gui/DrawSketchController.h
@@ -23,6 +23,7 @@
#ifndef SKETCHERGUI_DrawSketchController_H
#define SKETCHERGUI_DrawSketchController_H
+#include
#include
#include
@@ -350,6 +351,21 @@ public:
* It is intended to remote control the DrawSketchDefaultWidgetHandler
*/
void onViewValueChanged(int onviewparameterindex, double value)
+ {
+ // Since this method is used as a Qt slot we must handle
+ // all exceptions here
+ try {
+ tryViewValueChanged(onviewparameterindex, value);
+ }
+ catch (const Base::Exception& e) {
+ e.ReportException();
+ }
+ catch (const std::exception& e) {
+ Base::Console().Error("C++ exception in onViewValueChanged: %s\n", e.what());
+ }
+ }
+
+ void tryViewValueChanged(int onviewparameterindex, double value)
{
int nextindex = onviewparameterindex + 1;
if (isOnViewParameterOfCurrentMode(nextindex)) {
diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerEllipse.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerEllipse.h
index 5c319ba18a..1996013ef9 100644
--- a/src/Mod/Sketcher/Gui/DrawSketchHandlerEllipse.h
+++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerEllipse.h
@@ -325,9 +325,18 @@ private:
auto lprojx = projx.Length(); // Px = a cos t
auto lprojy = projy.Length(); // Py = b sin t
- double t = std::acos(lprojx / firstRadius);
-
- secondRadius = lprojy / std::sin(t); // b = Py / sin t
+ if (lprojx > firstRadius) {
+ secondRadius = 0.0;
+ }
+ else {
+ double t = std::acos(lprojx / firstRadius);
+ if (t == 0.0) {
+ secondRadius = 0.0;
+ }
+ else {
+ secondRadius = lprojy / std::sin(t); // b = Py / sin t
+ }
+ }
secondAxis = projy.Normalize() * secondRadius;
}