Code

fix curve::penultimate_point old behavior. no longer triggers 2geom exception.
authorjohanengelen <johanengelen@users.sourceforge.net>
Thu, 11 Sep 2008 22:03:22 +0000 (22:03 +0000)
committerjohanengelen <johanengelen@users.sourceforge.net>
Thu, 11 Sep 2008 22:03:22 +0000 (22:03 +0000)
src/display/curve.cpp

index 519def37df5b34fd8d5d91070a67e080a730f792..0b560883bd367b2df6de89107e12821469e87fcd 100644 (file)
@@ -398,15 +398,20 @@ SPCurve::second_point() const
 }
 
 /**
- * TODO: fix comment: Return the second-last point of last subpath or _movePos if curve too short.
+ * Return the second-last point of last subpath or first point when that last subpath has only a moveto.
  */
 boost::optional<Geom::Point>
 SPCurve::penultimate_point() const
 {
     boost::optional<Geom::Point> retval;
     if (!is_empty()) {
-        Geom::Curve const& back = _pathv.back().back_default();
-        retval = back.initialPoint();
+        Geom::Path const &lastpath = _pathv.back();
+        if (!lastpath.empty()) {
+            Geom::Curve const &back = lastpath.back_default();
+            retval = back.initialPoint();
+        } else {
+            retval = lastpath.initialPoint();
+        }
     }
 
     return retval;