summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f8f506c)
raw | patch | inline | side by side (parent: f8f506c)
author | johncoswell <johncoswell@users.sourceforge.net> | |
Sat, 5 Aug 2006 14:19:39 +0000 (14:19 +0000) | ||
committer | johncoswell <johncoswell@users.sourceforge.net> | |
Sat, 5 Aug 2006 14:19:39 +0000 (14:19 +0000) |
ChangeLog | patch | blob | history | |
src/node-context.cpp | patch | blob | history | |
src/nodepath.cpp | patch | blob | history |
diff --git a/ChangeLog b/ChangeLog
index c96f4f6945ec6159c9d9c55ddb48dfba5eddf50c..1a1180e74f3920cb4e37a033c91eb85cb9575449 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
+2006-08-05 John Bintz <jcoswell@coswellproductions.org>
+
+ * node-context.cpp, nodepath.cpp:
+
+ add checks to make sure given nodepath pointers are not
+ null before working with them
+
2006-08-01 MenTaLguY <mental@rydia.net>
* configure.ac: refactor pkg-config tests and add explicit cairo test
diff --git a/src/node-context.cpp b/src/node-context.cpp
index f213b58aaa88869cc1c87d6bf4e7cce81ad88d6b..3142e5b0eae313f7d112e5d6580387e9a7d46f40 100644 (file)
--- a/src/node-context.cpp
+++ b/src/node-context.cpp
SPDesktop *desktop = event_context->desktop;
Inkscape::Selection *selection = sp_desktop_selection (desktop);
+ // fixme: nc->nodepath can potentially become NULL after retrieving nc.
+ // A general method for handling this possibility should be created.
+ // For now, the number of checks for a NULL nc->nodepath have been
+ // increased, both here and in the called sp_nodepath_* functions.
+
SPNodeContext *nc = SP_NODE_CONTEXT(event_context);
double const nudge = prefs_get_double_attribute_limited("options.nudgedistance", "value", 2, 0, 1000); // in px
event_context->tolerance = prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100); // read every time, to make prefs changes really live
&& ( abs( (gint) event->motion.y - event_context->yp ) < event_context->tolerance ) ) {
break; // do not drag if we're within tolerance from origin
}
+
+ // The path went away while dragging; throw away any further motion
+ // events until the mouse pointer is released.
+ if (nc->hit && (nc->nodepath == NULL)) {
+ break;
+ }
+
// Once the user has moved farther than tolerance from the original location
// (indicating they intend to move the object, not click), then always process the
// motion notify coordinates as given (no snapping back to origin)
NR::Maybe<NR::Rect> b = Inkscape::Rubberband::get()->getRectangle();
if (nc->hit && !event_context->within_tolerance) { //drag curve
- sp_nodepath_update_repr (nc->nodepath, _("Drag curve"));
+ if (nc->nodepath) {
+ sp_nodepath_update_repr (nc->nodepath, _("Drag curve"));
+ }
} else if (b != NR::Nothing() && !event_context->within_tolerance) { // drag to select
if (nc->nodepath) {
sp_nodepath_select_rect(nc->nodepath, b.assume(), event->button.state & GDK_SHIFT_MASK);
diff --git a/src/nodepath.cpp b/src/nodepath.cpp
index d4aada20c32c48a85f713c8d9ad5e2ed4dd4c362..e3681f59adcd94e7a4225407bf8edf8ecf5728aa 100644 (file)
--- a/src/nodepath.cpp
+++ b/src/nodepath.cpp
*/
void sp_nodepath_update_repr(Inkscape::NodePath::Path *np, const gchar *annotation)
{
+ //fixme: np can be NULL, so check before proceeding
+ g_return_if_fail(np != NULL);
+
if (np->livarot_path) {
delete np->livarot_path;
np->livarot_path = NULL;
@@ -1551,6 +1554,9 @@ sp_nodepath_select_segment_near_point(Inkscape::NodePath::Path *nodepath, NR::Po
//find segment to segment
Inkscape::NodePath::Node *e = sp_nodepath_get_node_by_index(position.piece);
+ //fixme: this can return NULL, so check before proceeding.
+ g_return_if_fail(e != NULL);
+
gboolean force = FALSE;
if (!(e->selected && (!e->p.other || e->p.other->selected))) {
force = TRUE;
@@ -1604,6 +1610,10 @@ 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)
{
+ //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);
+
/* feel good is an arbitrary parameter that distributes the delta between handles
* if t of the drag point is less than 1/6 distance form the endpoint only
* the corresponding hadle is adjusted. This matches the behavior in GIMP