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-lpe-item.cpp | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) (limited to 'src/object/sp-lpe-item.cpp') 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) { -- cgit v1.2.3