From fe22d0226d17f9a17c6b1ae3e64ba97e40136f7a Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Mon, 16 Aug 2010 22:59:42 +0200 Subject: [PATCH] Connector tool: pointers should be nulled after snapping --- src/connector-context.cpp | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/src/connector-context.cpp b/src/connector-context.cpp index f862abac4..a1159e17d 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -768,7 +768,6 @@ connector_handle_button_press(SPConnectorContext *const cc, GdkEventButton const Geom::Point const event_dt = cc->desktop->w2d(event_w); SnapManager &m = cc->desktop->namedview->snap_manager; - m.setup(cc->desktop); switch (cc->state) { case SP_CONNECTOR_CONTEXT_STOP: @@ -790,7 +789,9 @@ connector_handle_button_press(SPConnectorContext *const cc, GdkEventButton const if (!found) { // This is the first point, so just snap it to the grid // as there's no other points to go off. + m.setup(cc->desktop); m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); + m.unSetup(); } spcc_connector_set_initial_point(cc, p); @@ -802,7 +803,9 @@ connector_handle_button_press(SPConnectorContext *const cc, GdkEventButton const case SP_CONNECTOR_CONTEXT_DRAGGING: { // This is the second click of a connector creation. + m.setup(cc->desktop); m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); + m.unSetup(); spcc_connector_set_subsequent_point(cc, p); spcc_connector_finish_segment(cc, p); @@ -824,7 +827,6 @@ connector_handle_button_press(SPConnectorContext *const cc, GdkEventButton const default: break; } - m.unSetup(); } else if (bevent.button == 3) { if (cc->state == SP_CONNECTOR_CONTEXT_REROUTING) { // A context menu is going to be triggered here, @@ -943,7 +945,6 @@ connector_handle_motion_notify(SPConnectorContext *const cc, GdkEventMotion cons if ( cc->mode == SP_CONNECTOR_CONTEXT_DRAWING_MODE ) { SnapManager &m = dt->namedview->snap_manager; - m.setup(dt); switch (cc->state) { case SP_CONNECTOR_CONTEXT_DRAGGING: @@ -951,7 +952,9 @@ connector_handle_motion_notify(SPConnectorContext *const cc, GdkEventMotion cons gobble_motion_events(mevent.state); // This is movement during a connector creation. if ( cc->npoints > 0 ) { + m.setup(dt); m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); + m.unSetup(); cc->selection->clear(); spcc_connector_set_subsequent_point(cc, p); ret = TRUE; @@ -963,7 +966,9 @@ connector_handle_motion_notify(SPConnectorContext *const cc, GdkEventMotion cons gobble_motion_events(GDK_BUTTON1_MASK); g_assert( SP_IS_PATH(cc->clickeditem)); + m.setup(dt); m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); + m.unSetup(); // Update the hidden path Geom::Matrix i2d = sp_item_i2d_affine(cc->clickeditem); @@ -994,11 +999,12 @@ connector_handle_motion_notify(SPConnectorContext *const cc, GdkEventMotion cons break; default: if (!sp_event_context_knot_mouseover(cc)) { + m.setup(dt); m.preSnap(Inkscape::SnapCandidatePoint(p, Inkscape::SNAPSOURCE_OTHER_HANDLE)); + m.unSetup(); } break; } - m.unSetup(); } else if ( cc->mode == SP_CONNECTOR_CONTEXT_EDITING_MODE ) { @@ -1030,7 +1036,6 @@ connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton con SPDocument *doc = sp_desktop_document(desktop); SnapManager &m = desktop->namedview->snap_manager; - m.setup(desktop); Geom::Point const event_w(revent.x, revent.y); @@ -1042,7 +1047,9 @@ connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton con //case SP_CONNECTOR_CONTEXT_POINT: case SP_CONNECTOR_CONTEXT_DRAGGING: { + m.setup(desktop); m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); + m.unSetup(); if (cc->within_tolerance) { @@ -1063,7 +1070,9 @@ connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton con } case SP_CONNECTOR_CONTEXT_REROUTING: { + m.setup(desktop); m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); + m.unSetup(); cc_connector_rerouting_finish(cc, &p); sp_document_ensure_up_to_date(doc); @@ -1087,7 +1096,9 @@ connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton con if (!cc->within_tolerance) { + m.setup(desktop); m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); + m.unSetup(); sp_knot_set_position(cc->selected_handle, p, 0); ConnectionPoint& cp = cc->connpthandles[cc->selected_handle]; cp.pos = p * sp_item_dt2i_affine(cc->active_shape); @@ -1100,7 +1111,9 @@ connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton con case SP_CONNECTOR_CONTEXT_NEWCONNPOINT: + m.setup(desktop); m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); + m.unSetup(); sp_knot_set_position(cc->selected_handle, p, 0); @@ -1123,7 +1136,6 @@ connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton con break; } } - m.unSetup(); } @@ -1196,21 +1208,20 @@ connector_handle_key_press(SPConnectorContext *const cc, guint const keyval) { // Put connection point at current position - SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(cc); - SnapManager &m = desktop->namedview->snap_manager; - m.setup(desktop); Geom::Point p = cc->selected_handle->pos; -// SPEventContext* event_context = SP_EVENT_CONTEXT( cc ); if (!cc->within_tolerance) { + SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(cc); + SnapManager &m = desktop->namedview->snap_manager; + m.setup(desktop); m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); + m.unSetup(); sp_knot_set_position(cc->selected_handle, p, 0); ConnectionPoint& cp = cc->connpthandles[cc->selected_handle]; cp.pos = p * sp_item_dt2i_affine(cc->active_shape); cc->active_shape->avoidRef->updateConnectionPoint(cp); } - m.unSetup(); cc->state = SP_CONNECTOR_CONTEXT_IDLE; ret = TRUE; @@ -1232,7 +1243,6 @@ connector_handle_key_press(SPConnectorContext *const cc, guint const keyval) SnapManager &m = desktop->namedview->snap_manager; m.setup(desktop); Geom::Point p = cc->selected_handle->pos; - m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); m.unSetup(); sp_knot_set_position(cc->selected_handle, p, 0); -- 2.30.2