Code

Fix node tool crash on path where the last subpath is a lone moveto
authorKrzysztof Kosiński <tweenk.pl@gmail.com>
Thu, 18 Feb 2010 00:34:15 +0000 (01:34 +0100)
committerKrzysztof Kosiński <tweenk.pl@gmail.com>
Thu, 18 Feb 2010 00:34:15 +0000 (01:34 +0100)
src/ui/tool/path-manipulator.cpp

index 13f1448b93997984ca3188968a154461274118a3..82fe5344026a443e447f0b823cde9067f7e8c070 100644 (file)
@@ -923,8 +923,11 @@ void PathManipulator::_createControlPointsFromGeometry()
     // so that _updateDragPoint doesn't crash on paths with naked movetos
     Geom::PathVector pathv = pathv_to_linear_and_cubic_beziers(_spcurve->get_pathvector());
     for (Geom::PathVector::iterator i = pathv.begin(); i != pathv.end(); ) {
+        // NOTE: this utilizes the fact that Geom::PathVector is an std::vector.
+        // When we erase an element, the next one slides into position,
+        // so we do not increment the iterator even though it is theoretically invalidated.
         if (i->empty()) {
-            pathv.erase(i++);
+            pathv.erase(i);
         } else {
             ++i;
         }