From 4007abe02509fc1e312a007fb26f31c5a595df26 Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Thu, 3 Apr 2014 21:04:51 -0400 Subject: Begin first stage of resolving issue with duplicate knots (bzr r13090.1.46) --- src/knotholder.cpp | 14 ++++++++------ src/live_effects/lpe-taperstroke.cpp | 10 ++++++++++ src/live_effects/pathoutlineprovider.cpp | 4 +++- src/sp-lpe-item.cpp | 5 +++++ 4 files changed, 26 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/knotholder.cpp b/src/knotholder.cpp index cf87423d4..94a041385 100644 --- a/src/knotholder.cpp +++ b/src/knotholder.cpp @@ -203,14 +203,16 @@ KnotHolder::knot_ungrabbed_handler(SPKnot */*knot*/, guint) /* do cleanup tasks (e.g., for LPE items write the parameter values * that were changed by dragging the handle to SVG) */ - if (SP_IS_LPE_ITEM(object)) { + if (dynamic_cast (object)) { // This writes all parameters to SVG. Is this sufficiently efficient or should we only // write the ones that were changed? - - Inkscape::LivePathEffect::Effect *lpe = SP_LPE_ITEM(object)->getCurrentLPE(); - if (lpe) { - LivePathEffectObject *lpeobj = lpe->getLPEObj(); - lpeobj->updateRepr(); + SPLPEItem * lpeitem = SP_LPE_ITEM(this->item); + if (lpeitem) { + Inkscape::LivePathEffect::Effect *lpe = lpeitem->getCurrentLPE(); + if (lpe) { + LivePathEffectObject *lpeobj = lpe->getLPEObj(); + lpeobj->updateRepr(); + } } } diff --git a/src/live_effects/lpe-taperstroke.cpp b/src/live_effects/lpe-taperstroke.cpp index c452c825c..dc70782c4 100644 --- a/src/live_effects/lpe-taperstroke.cpp +++ b/src/live_effects/lpe-taperstroke.cpp @@ -657,6 +657,11 @@ void KnotHolderEntityAttachBegin::knot_set(Geom::Point const &p, Geom::Point con Geom::Point const s = snap_knot_position(p, state); SPCurve *curve = SP_PATH(item)->get_curve_for_edit(); + if (!curve) { + //oops + lpe->attach_start.param_set_value(0); + return; + } Geom::PathVector pathv = curve->get_pathvector(); Piecewise > pwd2; Geom::Path p_in = return_at_first_cusp(pathv[0]); @@ -678,6 +683,11 @@ void KnotHolderEntityAttachEnd::knot_set(Geom::Point const &p, Geom::Point const Geom::Point const s = snap_knot_position(p, state); SPCurve *curve = SP_PATH(item)->get_curve_for_edit(); + if (!curve) { + //oops + lpe->attach_end.param_set_value(0); + return; + } Geom::PathVector pathv = curve->get_pathvector(); Piecewise > pwd2; Geom::Path p_in = return_at_first_cusp(pathv[0].reverse()); diff --git a/src/live_effects/pathoutlineprovider.cpp b/src/live_effects/pathoutlineprovider.cpp index 56f741417..a696728d6 100644 --- a/src/live_effects/pathoutlineprovider.cpp +++ b/src/live_effects/pathoutlineprovider.cpp @@ -1,3 +1,5 @@ +#include //g_critical + #include "pathoutlineprovider.h" #include "livarot/path-description.h" #include <2geom/angle.h> @@ -262,7 +264,7 @@ void extrapolate_curves(Geom::Path& path_builder, Geom::Curve* cbc1, Geom::Curve delete arc1; arc1 = NULL; } - } catch (std::exception ex) { + } catch (std::exception & ex) { printf("Exception occured, probably NaN or infinite valued points: %s\n", ex.what()); path_builder.appendNew(endPt); } diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp index 71aa9545a..eda34a0b5 100644 --- a/src/sp-lpe-item.cpp +++ b/src/sp-lpe-item.cpp @@ -553,6 +553,7 @@ bool SPLPEItem::hasBrokenPathEffect() const bool SPLPEItem::hasPathEffect() const { + if (!path_effect_list) return false; //nullptr sucks if (path_effect_list->empty()) { return false; } @@ -698,6 +699,7 @@ PathEffectList const SPLPEItem::getEffectList() const Inkscape::LivePathEffect::LPEObjectReference* SPLPEItem::getCurrentLPEReference() { + if (!this->hasPathEffect()) return NULL; if (!this->current_path_effect && !this->path_effect_list->empty()) { setCurrentPathEffect(this->path_effect_list->back()); } @@ -707,6 +709,9 @@ Inkscape::LivePathEffect::LPEObjectReference* SPLPEItem::getCurrentLPEReference( Inkscape::LivePathEffect::Effect* SPLPEItem::getCurrentLPE() { + if (path_effect_list == NULL) { + return NULL; + } Inkscape::LivePathEffect::LPEObjectReference* lperef = getCurrentLPEReference(); if (lperef && lperef->lpeobject) -- cgit v1.2.3