diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-01-20 13:29:04 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-01-20 13:29:04 (GMT) |
commit | 90392917a97c3bf87a24c0e140505197baeb8518 (patch) | |
tree | f995deaea1549b12aeb6b8b5b1bd317aa15c8461 /generic/tkCanvArc.c | |
parent | 3a960e4f4b01f314b3fdd56b8d86530f1361df05 (diff) | |
parent | c059c056e55ab968ac7c513bbd96720655e06da3 (diff) | |
download | tk-90392917a97c3bf87a24c0e140505197baeb8518.zip tk-90392917a97c3bf87a24c0e140505197baeb8518.tar.gz tk-90392917a97c3bf87a24c0e140505197baeb8518.tar.bz2 |
Rebase to latest trunk
Diffstat (limited to 'generic/tkCanvArc.c')
-rw-r--r-- | generic/tkCanvArc.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/generic/tkCanvArc.c b/generic/tkCanvArc.c index d2daa17..07813ea 100644 --- a/generic/tkCanvArc.c +++ b/generic/tkCanvArc.c @@ -13,6 +13,8 @@ #include "tkInt.h" #include "tkCanvas.h" +#include "float.h" + /* * The structure below defines the record for each arc item. */ @@ -183,7 +185,7 @@ static void ComputeArcBbox(Tk_Canvas canvas, ArcItem *arcPtr); static int ConfigureArc(Tcl_Interp *interp, Tk_Canvas canvas, Tk_Item *itemPtr, int objc, Tcl_Obj *const objv[], int flags); -static void ComputeArcFromHeight(ArcItem *arcPtr); +static int ComputeArcFromHeight(ArcItem *arcPtr); static int CreateArc(Tcl_Interp *interp, Tk_Canvas canvas, struct Tk_Item *itemPtr, int objc, Tcl_Obj *const objv[]); @@ -473,7 +475,14 @@ ConfigureArc( * overridden. */ if (arcPtr->height != 0) { - ComputeArcFromHeight(arcPtr); + int ret = ComputeArcFromHeight(arcPtr); + if (ret != TCL_OK) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "coordinates too close to define a chord")); + Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "ARC", + NULL); + return ret; + } ComputeArcBbox(canvas, arcPtr); } @@ -595,7 +604,7 @@ ConfigureArc( * end-point and height (!= 0). * * Results: - * None. + * TCL_ERROR if the chord length is zero, TCL_OK otherwise. * * Side effects: * The height parameter is set to 0 on exit. @@ -603,7 +612,7 @@ ConfigureArc( *-------------------------------------------------------------- */ -static void +static int ComputeArcFromHeight( ArcItem* arcPtr) { @@ -615,6 +624,10 @@ ComputeArcFromHeight( chordLen = hypot(arcPtr->endPoint[1] - arcPtr->startPoint[1], arcPtr->startPoint[0] - arcPtr->endPoint[0]); + + if (chordLen < DBL_EPSILON) + return TCL_ERROR; + chordDir[0] = (arcPtr->endPoint[0] - arcPtr->startPoint[0]) / chordLen; chordDir[1] = (arcPtr->endPoint[1] - arcPtr->startPoint[1]) / chordLen; chordCen[0] = (arcPtr->startPoint[0] + arcPtr->endPoint[0]) / 2; @@ -668,6 +681,8 @@ ComputeArcFromHeight( */ arcPtr->height = 0; + + return TCL_OK; } /* |