summaryrefslogtreecommitdiffstats
path: root/src/knot.cpp
diff options
context:
space:
mode:
authorAndrius Ramanauskas <knutux@gmail.com>2006-04-06 12:49:42 +0000
committerknutux <knutux@users.sourceforge.net>2006-04-06 12:49:42 +0000
commitf274306e8aa543f3e8de6fae7c8e0b421a0367c5 (patch)
tree40bcf34c2feaaaa453506322e71c7ad1db719643 /src/knot.cpp
parentone type and small update (diff)
downloadinkscape-f274306e8aa543f3e8de6fae7c8e0b421a0367c5.tar.gz
inkscape-f274306e8aa543f3e8de6fae7c8e0b421a0367c5.zip
two crashes while editing nodes (one of those is reported as bug 1453558).
* fixed by making SPKnotHolder a referenced class and adding ref/unref in knot_click_handler (which sometime change attributes and knot handler is destroyed before calling knotholder_update_knots); * fixed another crash by adding ref/unref to sp_knot_handler * also added signal disconnecting (bzr r445)
Diffstat (limited to 'src/knot.cpp')
-rw-r--r--src/knot.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/knot.cpp b/src/knot.cpp
index 01ccca693..95cadfdb7 100644
--- a/src/knot.cpp
+++ b/src/knot.cpp
@@ -195,6 +195,7 @@ static void sp_knot_init(SPKnot *knot)
knot->shape = SP_KNOT_SHAPE_SQUARE;
knot->mode = SP_KNOT_MODE_XOR;
knot->tip = NULL;
+ knot->_event_handler_id = 0;
knot->fill[SP_KNOT_STATE_NORMAL] = 0xffffff00;
knot->fill[SP_KNOT_STATE_MOUSEOVER] = 0xff0000ff;
@@ -228,6 +229,12 @@ static void sp_knot_dispose(GObject *object)
gdk_pointer_ungrab (GDK_CURRENT_TIME);
}
+ if (knot->_event_handler_id > 0)
+ {
+ g_signal_handler_disconnect(GTK_OBJECT (knot->item), knot->_event_handler_id);
+ knot->_event_handler_id = 0;
+ }
+
if (knot->item) {
gtk_object_destroy (GTK_OBJECT (knot->item));
knot->item = NULL;
@@ -280,6 +287,7 @@ static int sp_knot_handler(SPCanvasItem *item, GdkEvent *event, SPKnot *knot)
g_assert(knot != NULL);
g_assert(SP_IS_KNOT(knot));
+ g_object_ref(G_OBJECT(knot));
tolerance = prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100);
gboolean consumed = FALSE;
@@ -424,6 +432,7 @@ static int sp_knot_handler(SPCanvasItem *item, GdkEvent *event, SPKnot *knot)
break;
}
+ g_object_unref(G_OBJECT(knot));
return consumed;
}
@@ -454,8 +463,8 @@ SPKnot *sp_knot_new(SPDesktop *desktop, const gchar *tip)
"mode", SP_KNOT_MODE_XOR,
NULL);
- gtk_signal_connect(GTK_OBJECT(knot->item), "event",
- GTK_SIGNAL_FUNC(sp_knot_handler), knot);
+ knot->_event_handler_id = gtk_signal_connect(GTK_OBJECT(knot->item), "event",
+ GTK_SIGNAL_FUNC(sp_knot_handler), knot);
return knot;
}