Code

Make ControlPointSelection trackable to prevent random crashes
authorKrzysztof Kosiński <tweenk.pl@gmail.com>
Thu, 18 Feb 2010 00:22:55 +0000 (01:22 +0100)
committerKrzysztof Kosiński <tweenk.pl@gmail.com>
Thu, 18 Feb 2010 00:22:55 +0000 (01:22 +0100)
in the node tool

src/ui/tool/control-point-selection.h
src/ui/tool/path-manipulator.cpp

index 48c25c2852ef62736e5914035734c608827bfc55..d982d6becd94588ec7bf2a0bd144801c9706d124 100644 (file)
@@ -38,7 +38,7 @@ class SelectableControlPoint;
 namespace Inkscape {
 namespace UI {
 
-class ControlPointSelection : public Manipulator {
+class ControlPointSelection : public Manipulator, public sigc::trackable {
 public:
     ControlPointSelection(SPDesktop *d, SPCanvasGroup *th_group);
     ~ControlPointSelection();
index d2f90bbca3dc180e0d145e9565831bca1feb4b1b..13f1448b93997984ca3188968a154461274118a3 100644 (file)
@@ -103,7 +103,7 @@ PathManipulator::PathManipulator(MultiPathManipulator &mpm, SPPath *path,
     , _subpaths(*this)
     , _multi_path_manipulator(mpm)
     , _path(path)
-    , _spcurve(NULL)
+    , _spcurve(new SPCurve())
     , _dragpoint(new CurveDragPoint(*this))
     , _observer(new PathManipulatorObserver(this, SP_OBJECT(path)->repr))
     , _edit_transform(et)
@@ -146,7 +146,7 @@ PathManipulator::~PathManipulator()
     delete _dragpoint;
     delete _observer;
     gtk_object_destroy(_outline);
-    if (_spcurve) _spcurve->unref();
+    _spcurve->unref();
     clear();
 }
 
@@ -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(); ) {
-        if (i->empty()) pathv.erase(i++);
-        else ++i;
+        if (i->empty()) {
+            pathv.erase(i++);
+        } else {
+            ++i;
+        }
     }
     _spcurve->set_pathvector(pathv);
 
@@ -1123,13 +1126,11 @@ void PathManipulator::_getGeometry()
         Effect *lpe = LIVEPATHEFFECT(_path)->get_lpe();
         if (lpe) {
             PathParam *pathparam = dynamic_cast<PathParam *>(lpe->getParameter(_lpe_key.data()));
-            if (!_spcurve)
-                _spcurve = new SPCurve(pathparam->get_pathvector());
-            else
-                _spcurve->set_pathvector(pathparam->get_pathvector());
+            _spcurve->unref();
+            _spcurve = new SPCurve(pathparam->get_pathvector());
         }
     } else {
-        if (_spcurve) _spcurve->unref();
+        _spcurve->unref();
         _spcurve = sp_path_get_curve_for_edit(_path);
     }
 }
@@ -1152,7 +1153,7 @@ void PathManipulator::_setGeometry()
         }
     } else {
         if (_path->repr->attribute("inkscape:original-d"))
-            sp_path_set_original_curve(_path, _spcurve, true, false);
+            sp_path_set_original_curve(_path, _spcurve, false, false);
         else
             sp_shape_set_curve(SP_SHAPE(_path), _spcurve, false);
     }
@@ -1301,7 +1302,6 @@ void PathManipulator::_commit(Glib::ustring const &annotation)
  * point of the path. */
 void PathManipulator::_updateDragPoint(Geom::Point const &evp)
 {
-    // TODO find a way to make this faster (no transform required)
     Geom::Matrix to_desktop = _edit_transform * _i2d_transform;
     Geom::PathVector pv = _spcurve->get_pathvector();
     boost::optional<Geom::PathVectorPosition> pvp