aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlecoanet2004-10-18 11:21:08 +0000
committerlecoanet2004-10-18 11:21:08 +0000
commit9d046b50e4f7460641d2e808b5ef13cec2480978 (patch)
treef1df4cd7288d07fc34afc571ed452ed49ae63f85
parentbdcabf1748a1d206c6ccea4889e644d5dbad83c5 (diff)
downloadtkzinc-9d046b50e4f7460641d2e808b5ef13cec2480978.zip
tkzinc-9d046b50e4f7460641d2e808b5ef13cec2480978.tar.gz
tkzinc-9d046b50e4f7460641d2e808b5ef13cec2480978.tar.bz2
tkzinc-9d046b50e4f7460641d2e808b5ef13cec2480978.tar.xz
It is now possible to ask a coordinate from an empty
curve/contour without triggering an error. The return value is an empty list.
-rw-r--r--generic/Curve.c14
1 files changed, 14 insertions, 0 deletions
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;
}