summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e0bde32)
raw | patch | inline | side by side (parent: e0bde32)
author | buliabyak <buliabyak@users.sourceforge.net> | |
Fri, 5 Sep 2008 23:13:44 +0000 (23:13 +0000) | ||
committer | buliabyak <buliabyak@users.sourceforge.net> | |
Fri, 5 Sep 2008 23:13:44 +0000 (23:13 +0000) |
src/shape-editor.cpp | patch | blob | history | |
src/shape-editor.h | patch | blob | history |
diff --git a/src/shape-editor.cpp b/src/shape-editor.cpp
index c9a4fe55757067bca78fea707a7864a446ef9585..798e0181708fd7d0c022ecc498db1344473fb557 100644 (file)
--- a/src/shape-editor.cpp
+++ b/src/shape-editor.cpp
this->nodepath = NULL;
this->knotholder = NULL;
this->hit = false;
+ this->listener_attached_for = NULL;
}
ShapeEditor::~ShapeEditor() {
case SH_NODEPATH:
if (this->nodepath) {
old_repr = this->nodepath->repr;
- sp_repr_remove_listener_by_data(old_repr, this);
- Inkscape::GC::release(old_repr);
+ if (old_repr && old_repr == listener_attached_for) {
+ sp_repr_remove_listener_by_data(old_repr, this);
+ Inkscape::GC::release(old_repr);
+ listener_attached_for = NULL;
+ }
this->grab_node = -1;
sp_nodepath_destroy(this->nodepath);
case SH_KNOTHOLDER:
if (this->knotholder) {
old_repr = this->knotholder->repr;
- sp_repr_remove_listener_by_data(old_repr, this);
- Inkscape::GC::release(old_repr);
+ if (old_repr && old_repr == listener_attached_for) {
+ sp_repr_remove_listener_by_data(old_repr, this);
+ Inkscape::GC::release(old_repr);
+ listener_attached_for = NULL;
+ }
if (!keep_knotholder) {
delete this->knotholder;
return false;
}
-static void shapeeditor_np_event_attr_changed(Inkscape::XML::Node */*repr*/, gchar const *name,
+static void shapeeditor_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);
@@ -181,6 +189,7 @@ static void shapeeditor_np_event_attr_changed(Inkscape::XML::Node */*repr*/, gch
{
changed_np = !sh->has_local_change(SH_NODEPATH);
sh->decrement_local_change(SH_NODEPATH);
+
}
if (changed_np) {
@@ -197,17 +206,6 @@ static void shapeeditor_np_event_attr_changed(Inkscape::XML::Node */*repr*/, gch
}
}
- 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())
{
@@ -223,20 +221,10 @@ static void shapeeditor_kh_event_attr_changed(Inkscape::XML::Node */*repr*/, gch
sh->update_statusbar(); //TODO: sh->get_container()->update_statusbar();
}
-
-
-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 = {
+static Inkscape::XML::NodeEventVector shapeeditor_repr_events = {
NULL, /* child_added */
NULL, /* child_removed */
- shapeeditor_kh_event_attr_changed,
+ shapeeditor_event_attr_changed,
NULL, /* content_changed */
NULL /* order_changed */
};
// setting new listener
repr = SP_OBJECT_REPR(item);
- Inkscape::GC::anchor(repr);
- sp_repr_add_listener(repr, &shapeeditor_np_repr_events, this);
+ if (repr != listener_attached_for) {
+ Inkscape::GC::anchor(repr);
+ sp_repr_add_listener(repr, &shapeeditor_repr_events, this);
+ listener_attached_for = repr;
+ }
}
break;
this->knotholder->update_knots();
// setting new listener
repr = this->knotholder->repr;
- Inkscape::GC::anchor(repr);
- sp_repr_add_listener(repr, &shapeeditor_kh_repr_events, this);
+ if (repr != listener_attached_for) {
+ Inkscape::GC::anchor(repr);
+ sp_repr_add_listener(repr, &shapeeditor_repr_events, this);
+ listener_attached_for = repr;
+ }
}
break;
}
@@ -301,9 +295,10 @@ void ShapeEditor::set_item_lpe_path_parameter(SPItem *item, SPObject *lpeobject,
// setting new listener
Inkscape::XML::Node *repr = SP_OBJECT_REPR(lpeobject);
- if (repr) {
+ if (repr && repr != listener_attached_for) {
Inkscape::GC::anchor(repr);
- sp_repr_add_listener(repr, &shapeeditor_np_repr_events, this);
+ sp_repr_add_listener(repr, &shapeeditor_repr_events, this);
+ listener_attached_for = repr;
}
}
}
diff --git a/src/shape-editor.h b/src/shape-editor.h
index c8f5aa4191d0e6dd399612ef92a00c439477fa32..4e78869570839aea6979a8967b092f9b05c51c37 100644 (file)
--- a/src/shape-editor.h
+++ b/src/shape-editor.h
#include <libnr/nr-forward.h>
namespace Inkscape { namespace NodePath { class Path; } }
+namespace Inkscape { namespace XML { class Node; } }
#include "libnr/nr-path-code.h"
#include "libnr/nr-point.h"
bool hit;
NR::Point curvepoint_event; // int coords from event
NR::Point curvepoint_doc; // same, in doc coords
+
+ Inkscape::XML::Node *listener_attached_for;
};