summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabier Arraiza <jabier.arraiza@marker.es>2018-01-01 22:08:45 +0000
committerJabier Arraiza <jabier.arraiza@marker.es>2018-01-01 22:08:45 +0000
commit4c59c0717100f4c71ccef71a1f5b0521f3f7c0ad (patch)
treeb53ecdfe8785e4b05501eccc369efa783eda2e0b /src
parentCleanup comments and unused functions (diff)
downloadinkscape-4c59c0717100f4c71ccef71a1f5b0521f3f7c0ad.tar.gz
inkscape-4c59c0717100f4c71ccef71a1f5b0521f3f7c0ad.zip
Fixes crashes with knoth in bend and pattern along path
Diffstat (limited to 'src')
-rw-r--r--src/live_effects/lpe-bendpath.cpp37
-rw-r--r--src/live_effects/lpe-bendpath.h2
-rw-r--r--src/live_effects/lpe-patternalongpath.cpp38
-rw-r--r--src/live_effects/lpe-patternalongpath.h2
4 files changed, 38 insertions, 41 deletions
diff --git a/src/live_effects/lpe-bendpath.cpp b/src/live_effects/lpe-bendpath.cpp
index 093d7ac06..1988f34f9 100644
--- a/src/live_effects/lpe-bendpath.cpp
+++ b/src/live_effects/lpe-bendpath.cpp
@@ -44,6 +44,11 @@ namespace BeP {
class KnotHolderEntityWidthBendPath : public LPEKnotHolderEntity {
public:
KnotHolderEntityWidthBendPath(LPEBendPath * effect) : LPEKnotHolderEntity(effect) {}
+ virtual ~KnotHolderEntityWidthBendPath()
+ {
+ LPEBendPath *lpe = dynamic_cast<LPEBendPath *> (_effect);
+ lpe->_knot_entity = NULL;
+ }
virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state);
virtual Geom::Point knot_get() const;
};
@@ -67,7 +72,7 @@ LPEBendPath::LPEBendPath(LivePathEffectObject *lpeobject) :
prop_scale.param_set_digits(3);
prop_scale.param_set_increments(0.01, 0.10);
- knot_entity = NULL;
+ _knot_entity = NULL;
_provides_knotholder_entities = true;
apply_to_clippath_and_mask = true;
concatenate_before_pwd2 = true;
@@ -85,20 +90,14 @@ LPEBendPath::doBeforeEffect (SPLPEItem const* lpeitem)
original_bbox(lpeitem);
original_height = boundingbox_Y.max() - boundingbox_Y.min();
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
- if (desktop) {
- Inkscape::Selection * sel = SP_ACTIVE_DESKTOP->getSelection();
- SPItem * item = sel->singleItem();
- if (item->getId() == sp_lpe_item->getId() && static_cast<LPEBendPath*>(sp_lpe_item->getCurrentLPE()) == this) {
- if (knot_entity && knot_entity->knot) {
- if (hide_knot) {
- helper_path.clear();
- knot_entity->knot->hide();
- } else {
- knot_entity->knot->show();
- }
- knot_entity->update_knot();
- }
+ if (_knot_entity) {
+ if (hide_knot) {
+ helper_path.clear();
+ _knot_entity->knot->hide();
+ } else {
+ _knot_entity->knot->show();
}
+ _knot_entity->update_knot();
}
}
@@ -187,12 +186,12 @@ LPEBendPath::addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector<Geom:
void
LPEBendPath::addKnotHolderEntities(KnotHolder *knotholder, SPItem *item)
{
- knot_entity = new BeP::KnotHolderEntityWidthBendPath(this);
- knot_entity->create(NULL, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, _("Change the width"), SP_KNOT_SHAPE_CIRCLE);
- knotholder->add(knot_entity);
+ _knot_entity = new BeP::KnotHolderEntityWidthBendPath(this);
+ _knot_entity->create(NULL, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, _("Change the width"), SP_KNOT_SHAPE_CIRCLE);
+ knotholder->add(_knot_entity);
if (hide_knot) {
- knot_entity->knot->hide();
- knot_entity->update_knot();
+ _knot_entity->knot->hide();
+ _knot_entity->update_knot();
}
}
diff --git a/src/live_effects/lpe-bendpath.h b/src/live_effects/lpe-bendpath.h
index 74892201d..5f2c42fc3 100644
--- a/src/live_effects/lpe-bendpath.h
+++ b/src/live_effects/lpe-bendpath.h
@@ -59,7 +59,7 @@ private:
BoolParam scale_y_rel;
BoolParam vertical_pattern;
BoolParam hide_knot;
- KnotHolderEntity *knot_entity;
+ KnotHolderEntity * _knot_entity;
Geom::PathVector helper_path;
Geom::Piecewise<Geom::D2<Geom::SBasis> > uskeleton;
Geom::Piecewise<Geom::D2<Geom::SBasis> > n;
diff --git a/src/live_effects/lpe-patternalongpath.cpp b/src/live_effects/lpe-patternalongpath.cpp
index 33c07b2cb..efd1aec2d 100644
--- a/src/live_effects/lpe-patternalongpath.cpp
+++ b/src/live_effects/lpe-patternalongpath.cpp
@@ -47,6 +47,11 @@ namespace WPAP {
class KnotHolderEntityWidthPatternAlongPath : public LPEKnotHolderEntity {
public:
KnotHolderEntityWidthPatternAlongPath(LPEPatternAlongPath * effect) : LPEKnotHolderEntity(effect) {}
+ virtual ~KnotHolderEntityWidthPatternAlongPath()
+ {
+ LPEPatternAlongPath *lpe = dynamic_cast<LPEPatternAlongPath *> (_effect);
+ lpe->_knot_entity = NULL;
+ }
virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state);
virtual Geom::Point knot_get() const;
};
@@ -98,7 +103,7 @@ LPEPatternAlongPath::LPEPatternAlongPath(LivePathEffectObject *lpeobject) :
registerParameter(&fuse_tolerance);
prop_scale.param_set_digits(3);
prop_scale.param_set_increments(0.01, 0.10);
- knot_entity = NULL;
+ _knot_entity = NULL;
_provides_knotholder_entities = true;
}
@@ -116,21 +121,14 @@ LPEPatternAlongPath::doBeforeEffect (SPLPEItem const* lpeitem)
if (bbox) {
original_height = (*bbox)[Geom::Y].max() - (*bbox)[Geom::Y].min();
}
- SPDesktop *desktop = SP_ACTIVE_DESKTOP;
- if (desktop) {
- Inkscape::Selection * sel = SP_ACTIVE_DESKTOP->getSelection();
- SPItem * item = sel->singleItem();
- if (item->getId() == sp_lpe_item->getId() && static_cast<LPEPatternAlongPath*>(sp_lpe_item->getCurrentLPE()) == this) {
- if (knot_entity && knot_entity->knot) {
- if (hide_knot) {
- helper_path.clear();
- knot_entity->knot->hide();
- } else {
- knot_entity->knot->show();
- }
- knot_entity->update_knot();
- }
+ if (_knot_entity) {
+ if (hide_knot) {
+ helper_path.clear();
+ _knot_entity->knot->hide();
+ } else {
+ _knot_entity->knot->show();
}
+ _knot_entity->update_knot();
}
}
@@ -296,12 +294,12 @@ LPEPatternAlongPath::addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vect
void
LPEPatternAlongPath::addKnotHolderEntities(KnotHolder *knotholder, SPItem *item)
{
- knot_entity = new WPAP::KnotHolderEntityWidthPatternAlongPath(this);
- knot_entity->create(NULL, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, _("Change the width"), SP_KNOT_SHAPE_CIRCLE);
- knotholder->add(knot_entity);
+ _knot_entity = new WPAP::KnotHolderEntityWidthPatternAlongPath(this);
+ _knot_entity->create(NULL, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, _("Change the width"), SP_KNOT_SHAPE_CIRCLE);
+ knotholder->add(_knot_entity);
if (hide_knot) {
- knot_entity->knot->hide();
- knot_entity->update_knot();
+ _knot_entity->knot->hide();
+ _knot_entity->update_knot();
}
}
diff --git a/src/live_effects/lpe-patternalongpath.h b/src/live_effects/lpe-patternalongpath.h
index ded875a8b..50ff19e51 100644
--- a/src/live_effects/lpe-patternalongpath.h
+++ b/src/live_effects/lpe-patternalongpath.h
@@ -62,7 +62,7 @@ private:
BoolParam vertical_pattern;
BoolParam hide_knot;
ScalarParam fuse_tolerance;
- KnotHolderEntity *knot_entity;
+ KnotHolderEntity * _knot_entity;
Geom::PathVector helper_path;
void on_pattern_pasted();