diff --git a/src/sp-path.cpp b/src/sp-path.cpp
index 16e3bec400b4442bc9a61e28253ba54dbeae1b2b..51c3746c89b3dc4f6f4cfb4f76a8462b7943e5aa 100644 (file)
--- a/src/sp-path.cpp
+++ b/src/sp-path.cpp
#include "inkscape.h"
#include "style.h"
#include "message-stack.h"
-#include "prefs-utils.h"
#include "selection.h"
#define noPATH_VERBOSE
return Geom::identity();
}
+
static void
sp_path_update_patheffect(SPLPEItem *lpeitem, bool write)
{
SPShape * const shape = (SPShape *) lpeitem;
SPPath * const path = (SPPath *) lpeitem;
+ Inkscape::XML::Node *repr = SP_OBJECT_REPR(shape);
- if (sp_lpe_item_has_path_effect(lpeitem) && sp_lpe_item_path_effects_enabled(lpeitem)) {
- if (path->original_curve) {
- SPCurve *curve = path->original_curve->copy();
- sp_shape_set_curve_insync(shape, curve, TRUE);
- sp_lpe_item_perform_path_effect(SP_LPE_ITEM(shape), curve);
- SP_OBJECT(shape)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
- curve->unref();
-
- if (write) {
- // could also do SP_OBJECT(shape)->updateRepr(); but only the d attribute needs updating.
- Inkscape::XML::Node *repr = SP_OBJECT_REPR(shape);
- if ( shape->curve != NULL ) {
- gchar *str = sp_svg_write_path(shape->curve->get_pathvector());
- repr->setAttribute("d", str);
- g_free(str);
- } else {
- repr->setAttribute("d", NULL);
+ if (path->original_curve) {
+ SPCurve *curve = path->original_curve->copy();
+ /* if a path does not have an lpeitem applied, then reset the curve to the original_curve.
+ * This is very important for LPEs to work properly! (the bbox might be recalculated depending on the curve in shape)*/
+ sp_shape_set_curve_insync(shape, curve, TRUE);
+
+ bool success = sp_lpe_item_perform_path_effect(SP_LPE_ITEM(shape), curve);
+ if (success && write) {
+ // could also do SP_OBJECT(shape)->updateRepr(); but only the d attribute needs updating.
+ if ( shape->curve != NULL ) {
+ gchar *str = sp_svg_write_path(shape->curve->get_pathvector());
+ repr->setAttribute("d", str);
+ g_free(str);
+ } else {
+ repr->setAttribute("d", NULL);
+ }
+ } else {
+ // LPE was unsuccesfull. Read the old 'd'-attribute.
+ if (gchar const * value = repr->attribute("d")) {
+ Geom::PathVector pv = sp_svg_read_pathv(value);
+ SPCurve *oldcurve = new SPCurve(pv);
+ if (oldcurve) {
+ sp_shape_set_curve(shape, oldcurve, TRUE);
+ oldcurve->unref();
}
}
}
+ SP_OBJECT(shape)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+ curve->unref();
}
- // else: do nothing.
}