From 9cb142e8a749d329a7978ddd1cb43d68cf38920b Mon Sep 17 00:00:00 2001 From: bulia byak Date: Fri, 5 Jan 2007 13:46:30 +0000 Subject: robustize remembering the dragged segment - store node number, not pointer; fixes crash 1505549 (bzr r2134) --- src/node-context.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/node-context.cpp') 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 -- cgit v1.2.3