Code

fix Launchpad bug 593023: crash in constrained snap due to not calling setup() before...
authorDiederik van Lierop <mailat-signdiedenrezidotnl>
Thu, 1 Jul 2010 21:21:58 +0000 (23:21 +0200)
committerDiederik van Lierop <mailat-signdiedenrezidotnl>
Thu, 1 Jul 2010 21:21:58 +0000 (23:21 +0200)
src/gradient-drag.cpp
src/object-snapper.cpp

index 227a5f0033cb4cacbceff49fa65d52c17e9064b3..c9a982e42e92d9d454e1a3cd9518cf9b1116ffc8 100644 (file)
@@ -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);
         }
     }
index bced0ac44d22989a8f8faa8667e7694e319dc26f..983a6fedee8eda2423f46ab49833148d6eebdab4 100644 (file)
@@ -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