diff options
| author | Maximilian Albert <maximilian.albert@gmail.com> | 2008-09-08 22:20:36 +0000 |
|---|---|---|
| committer | cilix42 <cilix42@users.sourceforge.net> | 2008-09-08 22:20:36 +0000 |
| commit | b7b17f36b9e3d2814dcf0f4db1fb329976c2e85a (patch) | |
| tree | 7d9c97f8bd561cd70afd0fe44e507a6e4f91dfd3 /src/nodepath.cpp | |
| parent | add missing #include for gtk version check (diff) | |
| download | inkscape-b7b17f36b9e3d2814dcf0f4db1fb329976c2e85a.tar.gz inkscape-b7b17f36b9e3d2814dcf0f4db1fb329976c2e85a.zip | |
2geom update (rev. 1578); fixes node editing of some degenerate paths
(bzr r6784)
Diffstat (limited to 'src/nodepath.cpp')
| -rw-r--r-- | src/nodepath.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/nodepath.cpp b/src/nodepath.cpp index e049c40df..5345485e2 100644 --- a/src/nodepath.cpp +++ b/src/nodepath.cpp @@ -1960,11 +1960,15 @@ sp_nodepath_select_segment_near_point(Inkscape::NodePath::Path *nodepath, NR::Po SPCurve *curve = create_curve(nodepath); // perhaps we can use nodepath->curve here instead? Geom::PathVector const &pathv = curve->get_pathvector(); - Geom::PathVectorPosition pvpos = Geom::nearestPoint(pathv, p); + boost::optional<Geom::PathVectorPosition> pvpos = Geom::nearestPoint(pathv, p); + if (!pvpos) { + g_print ("Possible error?\n"); + return; + } // calculate index for nodepath's representation. - unsigned int segment_index = floor(pvpos.t) + 1; - for (unsigned int i = 0; i < pvpos.path_nr; ++i) { + unsigned int segment_index = floor(pvpos->t) + 1; + for (unsigned int i = 0; i < pvpos->path_nr; ++i) { segment_index += pathv[i].size() + 1; if (pathv[i].closed()) { segment_index += 1; @@ -2004,13 +2008,17 @@ sp_nodepath_add_node_near_point(Inkscape::NodePath::Path *nodepath, NR::Point p) SPCurve *curve = create_curve(nodepath); // perhaps we can use nodepath->curve here instead? Geom::PathVector const &pathv = curve->get_pathvector(); - Geom::PathVectorPosition pvpos = Geom::nearestPoint(pathv, p); + boost::optional<Geom::PathVectorPosition> pvpos = Geom::nearestPoint(pathv, p); + if (!pvpos) { + g_print ("Possible error?\n"); + return; + } // calculate index for nodepath's representation. double int_part; - double t = std::modf(pvpos.t, &int_part); + double t = std::modf(pvpos->t, &int_part); unsigned int segment_index = (unsigned int)int_part + 1; - for (unsigned int i = 0; i < pvpos.path_nr; ++i) { + for (unsigned int i = 0; i < pvpos->path_nr; ++i) { segment_index += pathv[i].size() + 1; if (pathv[i].closed()) { segment_index += 1; |
