From 19c5fdaf95392d09004f9fe7d92483ed97bd0fac Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Thu, 1 Jul 2010 23:21:58 +0200 Subject: [PATCH] fix Launchpad bug 593023: crash in constrained snap due to not calling setup() before snapping --- src/gradient-drag.cpp | 3 ++- src/object-snapper.cpp | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp index 227a5f003..c9a982e42 100644 --- a/src/gradient-drag.cpp +++ b/src/gradient-drag.cpp @@ -809,9 +809,10 @@ gr_knot_moved_midpoint_handler(SPKnot */*knot*/, Geom::Point const &ppointer, gu } else { p = snap_vector_midpoint (p, low_lim, high_lim, 0); if (!(state & GDK_SHIFT_MASK)) { + Inkscape::Snapper::ConstraintLine cl(low_lim, high_lim - low_lim); SPDesktop *desktop = dragger->parent->desktop; SnapManager &m = desktop->namedview->snap_manager; - Inkscape::Snapper::ConstraintLine cl(low_lim, high_lim - low_lim); + m.setup(desktop); m.constrainedSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE, cl); } } diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index bced0ac44..983a6fede 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -91,6 +91,12 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent, return; } + if (_snapmanager->getDesktop() == NULL) { + g_warning("desktop == NULL, so we cannot snap; please inform the developpers of this bug"); + // Apparently the etup() method from the SnapManager class hasn't been called before trying to snap. + } + + if (first_point) { _candidates->clear(); } @@ -99,7 +105,6 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent, bbox_to_snap_incl.expandBy(getSnapperTolerance()); // see? for (SPObject* o = sp_object_first_child(parent); o != NULL; o = SP_OBJECT_NEXT(o)) { - g_assert(_snapmanager->getDesktop() != NULL); if (SP_IS_ITEM(o) && !(_snapmanager->getDesktop()->itemIsHidden(SP_ITEM(o)) && !clip_or_mask)) { // Snapping to items in a locked layer is allowed // Don't snap to hidden objects, unless they're a clipped path or a mask -- 2.30.2