summaryrefslogtreecommitdiffstats
path: root/src/sp-path.cpp
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2015-03-18 18:07:14 +0000
committerJabiertxof <jtx@jtx.marker.es>2015-03-18 18:07:14 +0000
commite77956b4dbd029c9f6949f81fe083606f995c624 (patch)
tree74adda4df8986d65f70efb341c6235277361fd35 /src/sp-path.cpp
parentupdated code to work on 0.92 code (diff)
parentLatvian translation update (diff)
downloadinkscape-e77956b4dbd029c9f6949f81fe083606f995c624.tar.gz
inkscape-e77956b4dbd029c9f6949f81fe083606f995c624.zip
update to trunk
(bzr r12588.1.39)
Diffstat (limited to 'src/sp-path.cpp')
-rw-r--r--src/sp-path.cpp46
1 files changed, 31 insertions, 15 deletions
diff --git a/src/sp-path.cpp b/src/sp-path.cpp
index 5c076b7cb..42883588b 100644
--- a/src/sp-path.cpp
+++ b/src/sp-path.cpp
@@ -41,7 +41,7 @@
#include "document.h"
#include "desktop.h"
-#include "desktop-handles.h"
+
#include "desktop-style.h"
#include "ui/tools/tool-base.h"
#include "inkscape.h"
@@ -51,16 +51,6 @@
#define noPATH_VERBOSE
-#include "sp-factory.h"
-
-namespace {
- SPObject* createPath() {
- return new SPPath();
- }
-
- bool pathRegistered = SPFactory::instance().registerObject("svg:path", createPath);
-}
-
gint SPPath::nodesInPath() const
{
return _curve ? _curve->nodes_in_path() : 0;
@@ -140,10 +130,29 @@ void SPPath::build(SPDocument *document, Inkscape::XML::Node *repr) {
SPShape::build(document, repr);
- // this->readAttr( "inkscape:original-d" ); // lp1299948
+ // this->readAttr( "inkscape:original-d" ); // bug #1299948
+ // Why we take the long way of doing this probably needs some explaining:
+ //
+ // Normally upon being built, reading the inkscape:original-d attribute
+ // will cause the path to actually _write to its repr_ in response to this.
+ // This is bad, bad news if the attached effect refers to a path which
+ // hasn't been constructed yet.
+ //
+ // What will happen is the effect parameter will cause the effect to
+ // recalculate with a completely different value due to the parameter being
+ // "empty" -- even worse, an undo event might be created with the bad value,
+ // and undoing the current action could cause it to revert to the "bad"
+ // state. (After that, the referred object will be constructed and the
+ // reference will trigger the path effect to update and commit the right
+ // value to "d".)
+ //
+ // This mild nastiness here (don't recalculate effects on build) prevents a
+ // plethora of issues with effects with linked parameters doing wild and
+ // stupid things on new documents upon a mere undo.
+
if (gchar const* s = this->getRepr()->attribute("inkscape:original-d"))
{
- // write it to XML, and to my curve, but don't update patheffects
+ // Write the value to _curve_before_lpe, do not recalculate effects
Geom::PathVector pv = sp_svg_read_pathv(s);
SPCurve *curve = new SPCurve(pv);
@@ -158,10 +167,17 @@ void SPPath::build(SPDocument *document, Inkscape::XML::Node *repr) {
this->readAttr( "d" );
/* d is a required attribute */
- gchar const *d = this->getAttribute("d", NULL);
+ char const *d = this->getAttribute("d", NULL);
if (d == NULL) {
- this->setKeyValue( sp_attribute_lookup("d"), "");
+ // First see if calculating the path effect will generate "d":
+ this->update_patheffect(true);
+ d = this->getAttribute("d", NULL);
+
+ // I guess that didn't work, now we have nothing useful to write ("")
+ if (d == NULL) {
+ this->setKeyValue( sp_attribute_lookup("d"), "");
+ }
}
}