From 6e5d89bf9595648fcebcf76fd031ba1ea022d397 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Fri, 9 Mar 2018 00:50:57 +0100 Subject: Fixing refs --- src/object/sp-ellipse.cpp | 7 +------ src/object/sp-lpe-item.cpp | 33 ++++++++++++--------------------- src/object/sp-object.cpp | 6 +++++- src/object/sp-object.h | 1 - src/object/sp-shape.cpp | 6 ++++-- src/object/sp-shape.h | 2 +- src/object/sp-tref.cpp | 2 -- src/object/sp-use.cpp | 2 -- 8 files changed, 23 insertions(+), 36 deletions(-) (limited to 'src/object') diff --git a/src/object/sp-ellipse.cpp b/src/object/sp-ellipse.cpp index 95bfd6160..6fc34bbb2 100644 --- a/src/object/sp-ellipse.cpp +++ b/src/object/sp-ellipse.cpp @@ -481,12 +481,7 @@ void SPGenericEllipse::set_shape() * This is very important for LPEs to work properly! (the bbox might be recalculated depending on the curve in shape)*/ SPCurve * before = this->getCurveBeforeLPE(); if (before || this->hasPathEffectRecursive()) { - if (!before || before->get_pathvector() != c->get_pathvector()){ - this->setCurveBeforeLPE(c); - this->update_patheffect(false); - } else { - this->setCurveBeforeLPE(c); - } + this->setCurveBeforeLPE(c); } else { this->setCurveInsync(c); } diff --git a/src/object/sp-lpe-item.cpp b/src/object/sp-lpe-item.cpp index e0ef848af..17b2710f8 100644 --- a/src/object/sp-lpe-item.cpp +++ b/src/object/sp-lpe-item.cpp @@ -87,15 +87,7 @@ void SPLPEItem::release() { delete this->lpe_modified_connection_list; this->lpe_modified_connection_list = NULL; - PathEffectList::iterator it = this->path_effect_list->begin(); - - while ( it != this->path_effect_list->end() ) { - // unlink and delete all references in the list - (*it)->unlink(); - delete *it; - it = this->path_effect_list->erase(it); - } - + this->path_effect_list->clear(); // delete the list itself delete this->path_effect_list; this->path_effect_list = NULL; @@ -128,7 +120,6 @@ void SPLPEItem::set(unsigned int key, gchar const* value) { delete *it; it = this->path_effect_list->erase(it); } - // Parse the contents of "value" to rebuild the path effect reference list if ( value ) { std::istringstream iss(value); @@ -527,9 +518,9 @@ void SPLPEItem::addPathEffect(LivePathEffectObject * new_lpeobj) void SPLPEItem::removeCurrentPathEffect(bool keep_paths) { Inkscape::LivePathEffect::LPEObjectReference* lperef = this->getCurrentLPEReference(); - if (!lperef) + if (!lperef) { return; - + } if (Inkscape::LivePathEffect::Effect* effect_ = this->getCurrentLPE()) { effect_->keep_paths = keep_paths; effect_->doOnRemove(this); @@ -556,11 +547,14 @@ void SPLPEItem::removeAllPathEffects(bool keep_paths) return; } } - - PathEffectList::iterator it = this->path_effect_list->begin(); - - while ( it != this->path_effect_list->end() ) { - LivePathEffectObject *lpeobj = (*it)->lpeobject; + PathEffectList new_list = *this->path_effect_list; + std::list::iterator i; + for (i = new_list.begin(); i != new_list.end(); ++i) { + Inkscape::LivePathEffect::LPEObjectReference *lperef = (*i); + if (!lperef) { + continue; + } + LivePathEffectObject *lpeobj = lperef->lpeobject; if (lpeobj) { Inkscape::LivePathEffect::Effect * lpe = lpeobj->get_lpe(); if (lpe) { @@ -568,11 +562,8 @@ void SPLPEItem::removeAllPathEffects(bool keep_paths) lpe->doOnRemove(this); } } - // unlink and delete all references in the list - (*it)->unlink(); - ++it; } - this->path_effect_list->clear(); + new_list.clear(); this->getRepr()->setAttribute("inkscape:path-effect", NULL); if (!keep_paths) { diff --git a/src/object/sp-object.cpp b/src/object/sp-object.cpp index d3c429c2a..112a08fb9 100644 --- a/src/object/sp-object.cpp +++ b/src/object/sp-object.cpp @@ -17,6 +17,7 @@ #include #include + #include #include "helper/sp-marshal.h" @@ -27,6 +28,7 @@ #include "document.h" #include "preferences.h" #include "style.h" +#include "live_effects/lpeobject.h" #include "sp-factory.h" #include "sp-paint-server.h" #include "sp-root.h" @@ -454,6 +456,8 @@ void SPObject::requestOrphanCollection() { // leave it } else if (IS_COLORPROFILE(this)) { // leave it + } else if (IS_LIVEPATHEFFECT(this)) { + document->queueForOrphanCollection(this); } else { document->queueForOrphanCollection(this); @@ -1198,7 +1202,7 @@ void SPObject::requestDisplayUpdate(unsigned int flags) bool already_propagated = (!(this->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))); this->uflags |= flags; - + /* If requestModified has already been called on this object or one of its children, then we * don't need to set CHILD_MODIFIED on our ancestors because it's already been done. */ diff --git a/src/object/sp-object.h b/src/object/sp-object.h index ee092aa7b..f969e0c0a 100644 --- a/src/object/sp-object.h +++ b/src/object/sp-object.h @@ -58,7 +58,6 @@ class SPObject; #include #include #include - #include "version.h" #include "util/forward-pointer-iterator.h" diff --git a/src/object/sp-shape.cpp b/src/object/sp-shape.cpp index 07416650e..48252a1d9 100644 --- a/src/object/sp-shape.cpp +++ b/src/object/sp-shape.cpp @@ -733,7 +733,7 @@ void SPShape::print(SPPrintContext* ctx) { if (add_comments) { gchar * comment = g_strdup_printf("end '%s'", - this->defaultLabel()); + this->defaultLabel()); sp_print_comment(ctx, comment); g_free(comment); } @@ -1033,7 +1033,7 @@ void SPShape::setCurve(SPCurve *new_curve, unsigned int owner) * Sets _curve_before_lpe to refer to the curve. */ void -SPShape::setCurveBeforeLPE(SPCurve *new_curve, unsigned int owner) +SPShape::setCurveBeforeLPE(SPCurve *new_curve, unsigned int owner, bool write) { if (_curve_before_lpe) { _curve_before_lpe = _curve_before_lpe->unref(); @@ -1046,6 +1046,8 @@ SPShape::setCurveBeforeLPE(SPCurve *new_curve, unsigned int owner) _curve_before_lpe = new_curve->copy(); } } + sp_lpe_item_update_patheffect(this, true, write); + requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } /** diff --git a/src/object/sp-shape.h b/src/object/sp-shape.h index be097e390..76d11d52c 100644 --- a/src/object/sp-shape.h +++ b/src/object/sp-shape.h @@ -43,7 +43,7 @@ public: SPCurve * getCurveBeforeLPE (unsigned int owner = FALSE) const; SPCurve * getCurveForEdit (unsigned int owner = FALSE) const; void setCurve (SPCurve *curve, unsigned int owner = TRUE); - void setCurveBeforeLPE (SPCurve *new_curve, unsigned int owner = TRUE); + void setCurveBeforeLPE (SPCurve *new_curve, unsigned int owner = TRUE, bool write = FALSE); void setCurveInsync (SPCurve *curve, unsigned int owner = TRUE); int hasMarkers () const; int numberOfMarkers (int type) const; diff --git a/src/object/sp-tref.cpp b/src/object/sp-tref.cpp index dd44c5855..eae852a89 100644 --- a/src/object/sp-tref.cpp +++ b/src/object/sp-tref.cpp @@ -482,7 +482,6 @@ sp_tref_convert_to_tspan(SPObject *obj) new_tspan->updateRepr(); // Hold onto our SPObject and repr for now. - sp_object_ref(tref, NULL); Inkscape::GC::anchor(tref_repr); // Remove ourselves, not propagating delete events to avoid a @@ -495,7 +494,6 @@ sp_tref_convert_to_tspan(SPObject *obj) // Establish the succession and let go of our object. tref->setSuccessor(new_tspan); - sp_object_unref(tref, NULL); } } //////////////////// diff --git a/src/object/sp-use.cpp b/src/object/sp-use.cpp index 2837e56f1..af61e392b 100644 --- a/src/object/sp-use.cpp +++ b/src/object/sp-use.cpp @@ -695,7 +695,6 @@ SPItem *SPUse::unlink() { unlinked->updateRepr(); // Hold onto our SPObject and repr for now. - sp_object_ref(this, NULL); Inkscape::GC::anchor(repr); // Remove ourselves, not propagating delete events to avoid a @@ -715,7 +714,6 @@ SPItem *SPUse::unlink() { // Establish the succession and let go of our object. this->setSuccessor(unlinked); - sp_object_unref(this, NULL); SPItem *item = dynamic_cast(unlinked); g_assert(item != NULL); -- cgit v1.2.3