From: Krzysztof KosiƄski Date: Thu, 18 Feb 2010 00:22:55 +0000 (+0100) Subject: Make ControlPointSelection trackable to prevent random crashes X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=f83661e8aeee6ba14365a52f184800033cd00609;p=inkscape.git Make ControlPointSelection trackable to prevent random crashes in the node tool --- diff --git a/src/ui/tool/control-point-selection.h b/src/ui/tool/control-point-selection.h index 48c25c285..d982d6bec 100644 --- a/src/ui/tool/control-point-selection.h +++ b/src/ui/tool/control-point-selection.h @@ -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(); diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index d2f90bbca..13f1448b9 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -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(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 pvp