summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbulia byak <buliabyak@gmail.com>2007-01-05 13:46:30 +0000
committerbuliabyak <buliabyak@users.sourceforge.net>2007-01-05 13:46:30 +0000
commit9cb142e8a749d329a7978ddd1cb43d68cf38920b (patch)
tree3f3abbc18730c8139bf5e484a78a7cf0f2b7e9bd /src
parentport the fix from sp-text.cpp rev 11260 to fix bug 1628173 (diff)
downloadinkscape-9cb142e8a749d329a7978ddd1cb43d68cf38920b.tar.gz
inkscape-9cb142e8a749d329a7978ddd1cb43d68cf38920b.zip
robustize remembering the dragged segment - store node number, not pointer; fixes crash 1505549
(bzr r2134)
Diffstat (limited to 'src')
-rw-r--r--src/node-context.cpp10
-rw-r--r--src/node-context.h2
-rw-r--r--src/nodepath.cpp4
-rw-r--r--src/nodepath.h2
4 files changed, 14 insertions, 4 deletions
diff --git a/src/node-context.cpp b/src/node-context.cpp
index 2b30d067b..a4a51f676 100644
--- a/src/node-context.cpp
+++ b/src/node-context.cpp
@@ -134,6 +134,7 @@ sp_node_context_dispose(GObject *object)
}
if (nc->nodepath) {
+ nc->grab_node = -1;
sp_nodepath_destroy(nc->nodepath);
nc->nodepath = NULL;
}
@@ -164,6 +165,7 @@ sp_node_context_setup(SPEventContext *ec)
Inkscape::Selection *selection = sp_desktop_selection(ec->desktop);
SPItem *item = selection->singleItem();
+ nc->grab_node = -1;
nc->nodepath = NULL;
ec->shape_knot_holder = NULL;
@@ -223,6 +225,7 @@ sp_node_context_selection_changed(Inkscape::Selection *selection, gpointer data)
if (nc->nodepath) {
old_repr = nc->nodepath->repr;
+ nc->grab_node = -1;
sp_nodepath_destroy(nc->nodepath);
nc->nodepath = NULL;
}
@@ -240,6 +243,7 @@ sp_node_context_selection_changed(Inkscape::Selection *selection, gpointer data)
SPItem *item = selection->singleItem();
SPDesktop *desktop = selection->desktop();
+ nc->grab_node = -1;
nc->nodepath = NULL;
ec->shape_knot_holder = NULL;
if (item) {
@@ -281,6 +285,7 @@ sp_nodepath_update_from_item(SPNodeContext *nc, SPItem *item)
g_assert(desktop);
if (nc->nodepath) {
+ nc->grab_node = -1;
sp_nodepath_destroy(nc->nodepath);
nc->nodepath = NULL;
}
@@ -395,7 +400,7 @@ sp_node_context_is_over_stroke (SPNodeContext *nc, SPItem *item, NR::Point event
nc->curvepoint_event[NR::Y] = (gint) event_p [NR::Y];
nc->hit = true;
nc->grab_t = position.assume().t;
- nc->grab_node = sp_nodepath_get_node_by_index(position.assume().piece);
+ nc->grab_node = position.assume().piece;
}
return close;
@@ -588,6 +593,9 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event)
switch (nc->current_state) {
case SP_NODE_CONTEXT_NODE_DRAGGING:
{
+ if (nc->grab_node == -1) // don't know which segment to drag
+ break;
+
// We round off the extra precision in the motion coordinates provided
// by some input devices (like tablets). As we'll store the coordinates
// as integers in curvepoint_event we need to do this rounding before
diff --git a/src/node-context.h b/src/node-context.h
index d5067a66a..fae95cf43 100644
--- a/src/node-context.h
+++ b/src/node-context.h
@@ -51,7 +51,7 @@ struct SPNodeContext {
Inkscape::MessageContext *_node_message_context;
double grab_t;
- Inkscape::NodePath::Node * grab_node;
+ int grab_node; // number of node grabbed by sp_node_context_is_over_stroke
bool hit;
NR::Point curvepoint_event; // int coords from event
NR::Point curvepoint_doc; // same, in doc coords
diff --git a/src/nodepath.cpp b/src/nodepath.cpp
index e58a8b31d..8371c8241 100644
--- a/src/nodepath.cpp
+++ b/src/nodepath.cpp
@@ -1608,8 +1608,10 @@ sp_nodepath_add_node_near_point(Inkscape::NodePath::Path *nodepath, NR::Point p)
* cf. app/vectors/gimpbezierstroke.c, gimp_bezier_stroke_point_move_relative()
*/
void
-sp_nodepath_curve_drag(Inkscape::NodePath::Node * e, double t, NR::Point delta)
+sp_nodepath_curve_drag(int node, double t, NR::Point delta)
{
+ Inkscape::NodePath::Node *e = sp_nodepath_get_node_by_index(node);
+
//fixme: e and e->p can be NULL, so check for those before proceeding
g_return_if_fail(e != NULL);
g_return_if_fail(&e->p != NULL);
diff --git a/src/nodepath.h b/src/nodepath.h
index 0216af730..b675863d5 100644
--- a/src/nodepath.h
+++ b/src/nodepath.h
@@ -263,7 +263,7 @@ void sp_nodepath_selected_align(Inkscape::NodePath::Path *nodepath, NR::Dim2 axi
void sp_nodepath_selected_distribute(Inkscape::NodePath::Path *nodepath, NR::Dim2 axis);
void sp_nodepath_select_segment_near_point(Inkscape::NodePath::Path *nodepath, NR::Point p, bool toggle);
void sp_nodepath_add_node_near_point(Inkscape::NodePath::Path *nodepath, NR::Point p);
-void sp_nodepath_curve_drag(Inkscape::NodePath::Node * e, double t, NR::Point delta);
+void sp_nodepath_curve_drag(int node, double t, NR::Point delta);
Inkscape::NodePath::Node * sp_nodepath_get_node_by_index(int index);
/* possibly private functions */