From: cilix42 Date: Wed, 18 Jun 2008 22:30:22 +0000 (+0000) Subject: Update LPE helper paths "live" on changes X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=38b67355324899795e56e5440ba98c61ef46c13b;p=inkscape.git Update LPE helper paths "live" on changes --- diff --git a/src/shape-editor.cpp b/src/shape-editor.cpp index d5712525a..4b71184e4 100644 --- a/src/shape-editor.cpp +++ b/src/shape-editor.cpp @@ -198,7 +198,7 @@ void ShapeEditor::set_item(SPItem *item) { // or the LPE is invisible or it doesn't provide a knotholder itself this->nodepath = sp_nodepath_new(desktop, item, (prefs_get_int_attribute("tools.nodes", "show_handles", 1) != 0)); - } else if (lpe && lpe->isVisible() && lpe->showOrigPath()) { + } else if (lpe && lpe->isVisible()) { sp_lpe_item_add_temporary_canvasitems(lpeitem, desktop); } } diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp index 4c2ca3857..2ba1c86c2 100644 --- a/src/sp-lpe-item.cpp +++ b/src/sp-lpe-item.cpp @@ -118,6 +118,9 @@ sp_lpe_item_init(SPLPEItem *lpeitem) lpeitem->current_path_effect = NULL; new (&lpeitem->lpe_modified_connection) sigc::connection(); + + lpeitem->adding_helperpaths = false; + lpeitem->removing_helperpaths = false; } static void @@ -345,6 +348,13 @@ sp_lpe_item_update_patheffect (SPLPEItem *lpeitem, bool wholetree, bool write) top = lpeitem; } + // TODO: ditch inkscape_active_desktop() + SPDesktop *desktop = inkscape_active_desktop(); + if (desktop) { + sp_lpe_item_remove_temporary_canvasitems(lpeitem, desktop); + sp_lpe_item_add_temporary_canvasitems(lpeitem, desktop); + } + if (SP_LPE_ITEM_CLASS (G_OBJECT_GET_CLASS (top))->update_patheffect) { SP_LPE_ITEM_CLASS (G_OBJECT_GET_CLASS (top))->update_patheffect (top, write); } @@ -711,20 +721,38 @@ bool sp_lpe_item_path_effects_enabled(SPLPEItem *lpeitem) void sp_lpe_item_add_temporary_canvasitems(SPLPEItem *lpeitem, SPDesktop *desktop) { + if (lpeitem->adding_helperpaths) { + return; + } + lpeitem->adding_helperpaths = true; + // FIXME: for some reason it seems that we must create the variable lpe AFTER checking + // for adding_helperpaths == true; otherwise we get a crash on startup. why?? Inkscape::LivePathEffect::Effect *lpe = sp_lpe_item_get_current_lpe(lpeitem); if (lpe) { + // TODO: can we just update the tempitem's SPCurve instead of recreating it each time? lpe->addHelperPaths(lpeitem, desktop); } + lpeitem->adding_helperpaths = false; } void sp_lpe_item_remove_temporary_canvasitems(SPLPEItem *lpeitem, SPDesktop *desktop) { + g_return_if_fail(lpeitem); + g_return_if_fail(desktop); + + if (lpeitem->removing_helperpaths) { + return; + } + lpeitem->removing_helperpaths = true; + // destroy all temporary canvasitems created by LPEs std::vector::iterator i; for (i = lpeitem->lpe_helperpaths.begin(); i != lpeitem->lpe_helperpaths.end(); ++i) { desktop->remove_temporary_canvasitem(*i); } + + lpeitem->removing_helperpaths = false; } /* diff --git a/src/sp-lpe-item.h b/src/sp-lpe-item.h index 7691ce980..54642f27b 100644 --- a/src/sp-lpe-item.h +++ b/src/sp-lpe-item.h @@ -42,6 +42,9 @@ struct SPLPEItem : public SPItem { Inkscape::LivePathEffect::LPEObjectReference* current_path_effect; std::vector lpe_helperpaths; + bool adding_helperpaths; + bool removing_helperpaths; + sigc::connection lpe_modified_connection; };