From 9d046b50e4f7460641d2e808b5ef13cec2480978 Mon Sep 17 00:00:00 2001 From: lecoanet Date: Mon, 18 Oct 2004 11:21:08 +0000 Subject: It is now possible to ask a coordinate from an empty curve/contour without triggering an error. The return value is an empty list. --- generic/Curve.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'generic') diff --git a/generic/Curve.c b/generic/Curve.c index ed75c83..b580d56 100644 --- a/generic/Curve.c +++ b/generic/Curve.c @@ -1682,6 +1682,15 @@ Coords(ZnItem item, /*printf("contour %d, num_pts %d, index %d, cmd %d\n", contour, *num_pts, index, cmd);*/ /*printf("nb contours: %d\n", cv->shape.num_contours);*/ + /* + * Special case for reading an empty curve. + */ + if (((cmd == ZN_COORDS_READ) || (cmd == ZN_COORDS_READ_ALL)) && + (cv->shape.num_contours == 0)) { + *num_pts = 0; + return TCL_OK; + } + if (contour < 0) { contour += cv->shape.num_contours; } @@ -1792,6 +1801,11 @@ Coords(ZnItem item, } } else { + /* Special case for an empty contour. */ + if (c->num_points == 0) { + *num_pts = 0; + return TCL_OK; + } if (index < 0) { index += c->num_points; } -- cgit v1.1