
Can somebody tell me what is wrong with this code (fragments shown below). It throws some sort of exception which Inkscape catches when it gets down to
(*result).back().append(ls);
However, there is no problem doing
output.back().append(ls); // output is what result was named in the caller
in pathv_to_linear, where "output" was created. It is only a problem when the pathvector has been passed into the second (recursive) function.
Geom::PathVector pathv_to_linear( Geom::PathVector const &pathv, double maxdisp) { Geom::PathVector output; Geom::PathVector tmppath = pathv_to_linear_and_cubic_beziers(pathv); for (Geom::PathVector::const_iterator pit = tmppath.begin(); pit != tmppath.end(); ++pit) { output.push_back( Geom::Path() ); output.back().start( pit->initialPoint() ); output.back().close( pit->closed() ); for (Geom::Path::const_iterator cit = pit->begin(); cit != pit->end_open(); ++cit) { ... double xe,ye; int pset = 0; // set to 1 once a last point has been set recursive_bezier4( A[X], A[Y], B[X], B[Y], C[X], C[Y], D[X], D[Y], &xe, &ye, &pset, &output, 0); ... }
void recursive_bezier4(const double x1, const double y1, const double x2, const double y2, const double x3, const double y3, const double x4, const double y4, double *xe, double *ye, // last point added, if any int *pset, // 1 if value for xe,ye have been set Geom::PathVector *result, int level) { ... r1=Geom::Point(x23,y23); Geom::LineSegment ls(r0, r1); (*result).back().append(ls); // <---- Blows up here ... recursive_bezier4(x1, y1, x12, y12, x123, y123, x1234, y1234, xe, ye, pset, result, level+1); recursive_bezier4(x1234, y1234, x234, y234, x34, y34, x4, y4, xe, ye, pset, result, level+1); }
**************************************
I tried putting this
r0=Geom::Point(0.0,0.0); r1=Geom::Point(1.0,1.0); Geom::LineSegment ls(r0, r1); (*result).back().append(ls); // blows up here
at the top of recursive_bezier4, and it blew up in the first call, so it isn't losing the pointer in the recursion, it is invalid from the first call. However, there are no compiler errors or warnings.
I also tried it this way:
//in pathv_to_linear recursive_bezier4( A[X], A[Y], B[X], B[Y], C[X], C[Y], D[X], D[Y], &xe, &ye, &pset, output, 0);
void recursive_bezier4(const double x1, const double y1, const double x2, const double y2, const double x3, const double y3, const double x4, const double y4, double *xe, double *ye, // last point added, if any int *pset, // 1 if value for xe,ye have been set Geom::PathVector &result, int level) { .. r0=Geom::Point(0.0,0.0); r1=Geom::Point(1.0,1.0); Geom::LineSegment ls(r0, r1); result.back().append(ls);
but it had the same problem, or at least the (new) error was on the same line.
When run in gdb inkscape still caught the exception, so gdb did not break at the problem. My guess is that even if gdb had caught it it would not have been very informative, just some inscrutable error at the line where I already know the problem shows up.
Any ideas what might be causing this?
Thanks,
David Mathog mathog@...1176... Manager, Sequence Analysis Facility, Biology Division, Caltech