From 8283ce7ee10f55326dff69df260418eccea35633 Mon Sep 17 00:00:00 2001 From: johanengelen Date: Wed, 5 Sep 2007 18:55:34 +0000 Subject: [PATCH] LPE: fix undo bug for applying/removing effect --- src/live_effects/lpeobject.cpp | 11 ++++++++--- src/live_effects/parameter/enum.h | 2 +- src/ui/widget/registered-widget.cpp | 4 ++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/live_effects/lpeobject.cpp b/src/live_effects/lpeobject.cpp index de2baa470..8c45a4d3c 100644 --- a/src/live_effects/lpeobject.cpp +++ b/src/live_effects/lpeobject.cpp @@ -105,6 +105,8 @@ livepatheffect_build(SPObject *object, SPDocument *document, Inkscape::XML::Node #ifdef LIVEPATHEFFECT_VERBOSE g_message("Build livepatheffect"); #endif + g_assert(object != NULL); + g_assert(SP_IS_OBJECT(object)); if (((SPObjectClass *) livepatheffect_parent_class)->build) (* ((SPObjectClass *) livepatheffect_parent_class)->build)(object, document, repr); @@ -115,7 +117,7 @@ livepatheffect_build(SPObject *object, SPDocument *document, Inkscape::XML::Node repr->addListener (&livepatheffect_repr_events, object); } - /* Register ourselves */ + /* Register ourselves, is this necessary? */ // sp_document_add_resource(document, "path-effect", object); } @@ -125,12 +127,15 @@ livepatheffect_build(SPObject *object, SPDocument *document, Inkscape::XML::Node static void livepatheffect_release(SPObject *object) { - LivePathEffectObject *lpeobj = LIVEPATHEFFECT(object); - #ifdef LIVEPATHEFFECT_VERBOSE g_print("Releasing livepatheffect"); #endif + LivePathEffectObject *lpeobj = LIVEPATHEFFECT(object); + + SP_OBJECT_REPR(object)->removeListenerByData(object); + + /* if (SP_OBJECT_DOCUMENT(object)) { // Unregister ourselves diff --git a/src/live_effects/parameter/enum.h b/src/live_effects/parameter/enum.h index 9b8c0f91e..4fd948ee6 100644 --- a/src/live_effects/parameter/enum.h +++ b/src/live_effects/parameter/enum.h @@ -47,8 +47,8 @@ public: if (!regenum) { regenum = new Inkscape::UI::Widget::RegisteredEnum(); regenum->init(param_label, param_tooltip, param_key, *enumdataconv, *param_wr, param_effect->getRepr(), param_effect->getSPDoc()); - regenum->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change enum parameter")); regenum->combobox()->set_active_by_id(value); + regenum->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change enum parameter")); } return dynamic_cast (regenum->labelled); }; diff --git a/src/ui/widget/registered-widget.cpp b/src/ui/widget/registered-widget.cpp index c2c7e593c..c99fcb5ff 100644 --- a/src/ui/widget/registered-widget.cpp +++ b/src/ui/widget/registered-widget.cpp @@ -67,8 +67,10 @@ RegisteredWidget::write_to_xml(const char * svgstr) bool saved = sp_document_get_undo_sensitive (local_doc); sp_document_set_undo_sensitive (local_doc, false); + if (!write_undo) local_repr->setAttribute(_key.c_str(), svgstr); local_doc->rroot->setAttribute("sodipodi:modified", "true"); + sp_document_set_undo_sensitive (local_doc, saved); if (write_undo) { local_repr->setAttribute(_key.c_str(), svgstr); @@ -128,8 +130,6 @@ RegisteredCheckButton::on_toggled() (*i)->set_sensitive(_button->get_active()); } - write_to_xml(_button->get_active() ? "true" : "false"); - _wr->setUpdating (false); } -- 2.30.2