summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMaximilian Albert <maximilian.albert@gmail.com>2008-06-18 22:30:22 +0000
committercilix42 <cilix42@users.sourceforge.net>2008-06-18 22:30:22 +0000
commit9f73c6a042a7da94457ef3adcc142b626fbbc905 (patch)
tree7e41b52903ea44aef046c9d6ad6b385aac44b6fb /src
parentMake knotholder members protected (diff)
downloadinkscape-9f73c6a042a7da94457ef3adcc142b626fbbc905.tar.gz
inkscape-9f73c6a042a7da94457ef3adcc142b626fbbc905.zip
Update LPE helper paths "live" on changes
(bzr r5995)
Diffstat (limited to 'src')
-rw-r--r--src/shape-editor.cpp2
-rw-r--r--src/sp-lpe-item.cpp28
-rw-r--r--src/sp-lpe-item.h3
3 files changed, 32 insertions, 1 deletions
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<Inkscape::Display::TemporaryItem*>::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<Inkscape::Display::TemporaryItem*> lpe_helperpaths;
+ bool adding_helperpaths;
+ bool removing_helperpaths;
+
sigc::connection lpe_modified_connection;
};