From: scislac Date: Mon, 5 Oct 2009 20:47:05 +0000 (+0000) Subject: Patch by Johan to fix crashing by undefined path parameters in 4 LPEs X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=307c164a7b61c5bfd08eaf25236383f070801bb1;p=inkscape.git Patch by Johan to fix crashing by undefined path parameters in 4 LPEs --- diff --git a/src/live_effects/lpe-envelope.cpp b/src/live_effects/lpe-envelope.cpp index a730f14ff..abd975b4e 100755 --- a/src/live_effects/lpe-envelope.cpp +++ b/src/live_effects/lpe-envelope.cpp @@ -69,6 +69,15 @@ LPEEnvelope::doEffect_pwd2 (Geom::Piecewise > const & pwd using namespace Geom; + // Don't allow empty path parameters: + if ( bend_path1.get_pathvector().empty() + || bend_path2.get_pathvector().empty() + || bend_path3.get_pathvector().empty() + || bend_path4.get_pathvector().empty() ) + { + return pwd2_in; + } + /* The code below is inspired from the Bend Path code developed by jfb and mgsloan Please, read it before tring to understand this one diff --git a/src/live_effects/lpe-interpolate.cpp b/src/live_effects/lpe-interpolate.cpp index e19d2e6e7..e77a392e9 100644 --- a/src/live_effects/lpe-interpolate.cpp +++ b/src/live_effects/lpe-interpolate.cpp @@ -52,8 +52,13 @@ LPEInterpolate::~LPEInterpolate() Geom::PathVector LPEInterpolate::doEffect_path (Geom::PathVector const & path_in) { - if ( (path_in.size() < 2) || (number_of_steps < 2)) + if ( (path_in.size() < 2) || (number_of_steps < 2)) { return path_in; + } + // Don't allow empty path parameter: + if ( trajectory_path.get_pathvector().empty() ) { + return path_in; + } std::vector path_out; diff --git a/src/live_effects/lpe-mirror_symmetry.cpp b/src/live_effects/lpe-mirror_symmetry.cpp index cd724b70e..a3a0faf37 100644 --- a/src/live_effects/lpe-mirror_symmetry.cpp +++ b/src/live_effects/lpe-mirror_symmetry.cpp @@ -60,6 +60,11 @@ LPEMirrorSymmetry::doOnApply (SPLPEItem *lpeitem) std::vector LPEMirrorSymmetry::doEffect_path (std::vector const & path_in) { + // Don't allow empty path parameter: + if ( reflection_line.get_pathvector().empty() ) { + return path_in; + } + std::vector path_out; if (!discard_orig_path) { path_out = path_in; diff --git a/src/live_effects/lpe-patternalongpath.cpp b/src/live_effects/lpe-patternalongpath.cpp index 29c5517bf..45b2b67b4 100644 --- a/src/live_effects/lpe-patternalongpath.cpp +++ b/src/live_effects/lpe-patternalongpath.cpp @@ -33,7 +33,7 @@ B is a map t --> B(t) = ( a(t), b(t) ). The first step is to re-parametrize B by its arc length: this is the parametrization in which a point p on B is located by its distance s from start. One obtains a new map s --> U(s) = (a'(s),b'(s)), that still describes the same path B, but where the distance along B from start to U(s) is s itself. -We also need a unit normal to the path. This can be obtained by computing a unit tangent vector, and rotate it by 90°. Call this normal vector N(s). +We also need a unit normal to the path. This can be obtained by computing a unit tangent vector, and rotate it by 90�. Call this normal vector N(s). The basic deformation associated to B is then given by: @@ -104,6 +104,11 @@ LPEPatternAlongPath::doEffect_pwd2 (Geom::Piecewise > con { using namespace Geom; + // Don't allow empty path parameter: + if ( pattern.get_pathvector().empty() ) { + return pwd2_in; + } + /* Much credit should go to jfb and mgsloan of lib2geom development for the code below! */ Piecewise > output; std::vector > > pre_output;