Code

LPE: fix undo bug for applying/removing effect
authorjohanengelen <johanengelen@users.sourceforge.net>
Wed, 5 Sep 2007 18:55:34 +0000 (18:55 +0000)
committerjohanengelen <johanengelen@users.sourceforge.net>
Wed, 5 Sep 2007 18:55:34 +0000 (18:55 +0000)
src/live_effects/lpeobject.cpp
src/live_effects/parameter/enum.h
src/ui/widget/registered-widget.cpp

index de2baa4708063977224bcfdbb2c194bef86a9c60..8c45a4d3c98dd70e0a71e4d0afbfd627cd61967a 100644 (file)
@@ -105,6 +105,8 @@ livepatheffect_build(SPObject *object, SPDocument *document, Inkscape::XML::Node
 #ifdef LIVEPATHEFFECT_VERBOSE\r
     g_message("Build livepatheffect");\r
 #endif\r
+    g_assert(object != NULL);\r
+    g_assert(SP_IS_OBJECT(object));\r
 \r
     if (((SPObjectClass *) livepatheffect_parent_class)->build)\r
         (* ((SPObjectClass *) livepatheffect_parent_class)->build)(object, document, repr);\r
@@ -115,7 +117,7 @@ livepatheffect_build(SPObject *object, SPDocument *document, Inkscape::XML::Node
         repr->addListener (&livepatheffect_repr_events, object);\r
     }\r
 \r
-    /* Register ourselves */\r
+    /* Register ourselves, is this necessary? */\r
 //    sp_document_add_resource(document, "path-effect", object);\r
 }\r
 \r
@@ -125,12 +127,15 @@ livepatheffect_build(SPObject *object, SPDocument *document, Inkscape::XML::Node
 static void\r
 livepatheffect_release(SPObject *object)\r
 {\r
-    LivePathEffectObject *lpeobj = LIVEPATHEFFECT(object);\r
-\r
 #ifdef LIVEPATHEFFECT_VERBOSE\r
     g_print("Releasing livepatheffect");\r
 #endif\r
 \r
+    LivePathEffectObject *lpeobj = LIVEPATHEFFECT(object);\r
+\r
+    SP_OBJECT_REPR(object)->removeListenerByData(object);\r
+\r
+\r
 /*\r
     if (SP_OBJECT_DOCUMENT(object)) {\r
         // Unregister ourselves\r
index 9b8c0f91ebca320aaae7817864fe0c02ecc1d5d5..4fd948ee6eb793f1674e3771ef12c62cb4f599c2 100644 (file)
@@ -47,8 +47,8 @@ public:
         if (!regenum) {\r
             regenum = new Inkscape::UI::Widget::RegisteredEnum<E>();\r
             regenum->init(param_label, param_tooltip, param_key, *enumdataconv, *param_wr, param_effect->getRepr(), param_effect->getSPDoc());\r
-            regenum->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change enum parameter"));\r
             regenum->combobox()->set_active_by_id(value);\r
+            regenum->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change enum parameter"));\r
         }\r
         return dynamic_cast<Gtk::Widget *> (regenum->labelled);\r
     };\r
index c2c7e593c22d3289a0da6ad69d07d70af39628bb..c99fcb5ffc2a3eedb46f99de7296b54e157696bf 100644 (file)
@@ -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);
 }