Code

fix crash: separate np and kh listeners so that np listener is not fired twice when...
authorbuliabyak <buliabyak@users.sourceforge.net>
Fri, 5 Sep 2008 19:48:07 +0000 (19:48 +0000)
committerbuliabyak <buliabyak@users.sourceforge.net>
Fri, 5 Sep 2008 19:48:07 +0000 (19:48 +0000)
src/shape-editor.cpp

index 91fdeca350508f31324731f170b819b99a3c2a73..c9a4fe55757067bca78fea707a7864a446ef9585 100644 (file)
@@ -168,12 +168,11 @@ bool ShapeEditor::nodepath_edits_repr_key(gchar const *name) {
     return false;
 }
 
-static void shapeeditor_event_attr_changed(Inkscape::XML::Node */*repr*/, gchar const *name,
+static void shapeeditor_np_event_attr_changed(Inkscape::XML::Node */*repr*/, gchar const *name,
                                            gchar const */*old_value*/, gchar const */*new_value*/,
                                            bool /*is_interactive*/, gpointer data)
 {
     gboolean changed_np = FALSE;
-    gboolean changed_kh = FALSE;
 
     g_assert(data);
     ShapeEditor *sh = ((ShapeEditor *) data);
@@ -182,7 +181,6 @@ static void shapeeditor_event_attr_changed(Inkscape::XML::Node */*repr*/, gchar
     {
         changed_np = !sh->has_local_change(SH_NODEPATH);
         sh->decrement_local_change(SH_NODEPATH);
-
     }
 
     if (changed_np) {
@@ -199,6 +197,17 @@ static void shapeeditor_event_attr_changed(Inkscape::XML::Node */*repr*/, gchar
         }
     }
 
+    sh->update_statusbar(); //TODO: sh->get_container()->update_statusbar();
+}
+
+static void shapeeditor_kh_event_attr_changed(Inkscape::XML::Node */*repr*/, gchar const *name,
+                                           gchar const */*old_value*/, gchar const */*new_value*/,
+                                           bool /*is_interactive*/, gpointer data)
+{
+    gboolean changed_kh = FALSE;
+
+    g_assert(data);
+    ShapeEditor *sh = ((ShapeEditor *) data);
 
     if (sh->has_knotholder())
     {
@@ -214,10 +223,20 @@ static void shapeeditor_event_attr_changed(Inkscape::XML::Node */*repr*/, gchar
     sh->update_statusbar(); //TODO: sh->get_container()->update_statusbar();
 }
 
-static Inkscape::XML::NodeEventVector shapeeditor_repr_events = {
+
+
+static Inkscape::XML::NodeEventVector shapeeditor_np_repr_events = {
+    NULL, /* child_added */
+    NULL, /* child_removed */
+    shapeeditor_np_event_attr_changed,
+    NULL, /* content_changed */
+    NULL  /* order_changed */
+};
+
+static Inkscape::XML::NodeEventVector shapeeditor_kh_repr_events = {
     NULL, /* child_added */
     NULL, /* child_removed */
-    shapeeditor_event_attr_changed,
+    shapeeditor_kh_event_attr_changed,
     NULL, /* content_changed */
     NULL  /* order_changed */
 };
@@ -243,7 +262,7 @@ void ShapeEditor::set_item(SPItem *item, SubType type, bool keep_knotholder) {
                     // setting new listener
                     repr = SP_OBJECT_REPR(item);
                     Inkscape::GC::anchor(repr);
-                    sp_repr_add_listener(repr, &shapeeditor_repr_events, this);
+                    sp_repr_add_listener(repr, &shapeeditor_np_repr_events, this);
                 }
                 break;
 
@@ -257,7 +276,7 @@ void ShapeEditor::set_item(SPItem *item, SubType type, bool keep_knotholder) {
                     // setting new listener
                     repr = this->knotholder->repr;
                     Inkscape::GC::anchor(repr);
-                    sp_repr_add_listener(repr, &shapeeditor_repr_events, this);
+                    sp_repr_add_listener(repr, &shapeeditor_kh_repr_events, this);
                 }
                 break;
         }
@@ -284,7 +303,7 @@ void ShapeEditor::set_item_lpe_path_parameter(SPItem *item, SPObject *lpeobject,
             Inkscape::XML::Node *repr = SP_OBJECT_REPR(lpeobject);
             if (repr) {
                 Inkscape::GC::anchor(repr);
-                sp_repr_add_listener(repr, &shapeeditor_repr_events, this);
+                sp_repr_add_listener(repr, &shapeeditor_np_repr_events, this);
             }
         }
     }