From fe229d823cc9f3a4cdd48fb15d8f5a433a71027c Mon Sep 17 00:00:00 2001 From: buliabyak Date: Thu, 13 Aug 2009 20:18:16 +0000 Subject: [PATCH] fix 304018 --- src/nodepath.cpp | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/nodepath.cpp b/src/nodepath.cpp index 74d0758a7..5b2a738d3 100644 --- a/src/nodepath.cpp +++ b/src/nodepath.cpp @@ -201,6 +201,19 @@ sp_nodepath_create_helperpaths(Inkscape::NodePath::Path *np) { } } +static void +sp_nodepath_destroy_helperpaths(Inkscape::NodePath::Path *np) { + for (HelperPathList::iterator i = np->helper_path_vec.begin(); i != np->helper_path_vec.end(); ++i) { + for (std::vector::iterator j = (*i).second.begin(); j != (*i).second.end(); ++j) { + GtkObject *temp = *j; + *j = NULL; + gtk_object_destroy(temp); + } + } + np->helper_path_vec.clear(); +} + +/** updates canvas items from the effect's helper paths */ void sp_nodepath_update_helperpaths(Inkscape::NodePath::Path *np) { //std::map > helper_path_vec; @@ -211,13 +224,15 @@ sp_nodepath_update_helperpaths(Inkscape::NodePath::Path *np) { SPLPEItem *lpeitem = SP_LPE_ITEM(np->item); PathEffectList lpelist = sp_lpe_item_get_effect_list(lpeitem); + + /* The number or type or LPEs may have changed, so we need to clear and recreate our + * helper_path_vec to make sure it is in sync */ + sp_nodepath_destroy_helperpaths(np); + sp_nodepath_create_helperpaths(np); + for (PathEffectList::iterator i = lpelist.begin(); i != lpelist.end(); ++i) { Inkscape::LivePathEffect::Effect *lpe = (*i)->lpeobject->get_lpe(); if (lpe) { - /* update canvas items from the effect's helper paths; note that this code relies on the - * fact that getHelperPaths() will always return the same number of helperpaths in the same - * order as during their creation in sp_nodepath_create_helperpaths - */ std::vector hpaths = lpe->getHelperPaths(lpeitem); for (unsigned int j = 0; j < hpaths.size(); ++j) { SPCurve *curve = new SPCurve(hpaths[j]); @@ -229,19 +244,6 @@ sp_nodepath_update_helperpaths(Inkscape::NodePath::Path *np) { } } -static void -sp_nodepath_destroy_helperpaths(Inkscape::NodePath::Path *np) { - for (HelperPathList::iterator i = np->helper_path_vec.begin(); i != np->helper_path_vec.end(); ++i) { - for (std::vector::iterator j = (*i).second.begin(); j != (*i).second.end(); ++j) { - GtkObject *temp = *j; - *j = NULL; - gtk_object_destroy(temp); - } - } - np->helper_path_vec.clear(); -} - - /** * \brief Creates new nodepath from item * -- 2.30.2