crash when activating "snap to path" mode after changing stroke width (no focus-out-event)

Bug #669537 reported by tbnorth
24
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Inkscape
Fix Released
High
Adonis Papaderos

Bug Description

just compiled r9870 on ubuntu 10.4.1 64 bit.

With a path in edit mode with the node tool, I switch on snap to path by clicking the button with the little green snake icon.

Emergency save occurs. I can reproduce it with these steps, not sure which are critical:

- ./src/inkscape
- maximize window
- zoom in
- draw three node path (straight internodes) (bezier curves tool)
- click fill stroke thing in bottom left to bring up fill stroke dialog (docked)
- go to stroke style tab
- mouse wheel increase width
- click snap to path button in snapping button bar
- crash

(hmm, I guess having the path in node tool edit mode isn't required then

shell output follows:

trunk_64> ./src/inkscape

ERROR:document-undo.cpp:172:void sp_document_maybe_done(SPDocument*, const gchar*, unsigned int, Glib::ustring): assertion failed: (doc->priv->sensitive)

Emergency save activated!

Emergency save document locations:
  /home/tbrown/New document 1.2010_11_01_11_45_38.0.svg
Emergency save completed. Inkscape will close now.
If you can reproduce this crash, please file a bug at www.inkscape.org
with a detailed description of the steps leading to the crash, so we can fix it.

(inkscape:1403): Gtk-WARNING **: GtkEntry - did not receive focus-out-event. If you
connect a handler to this signal, it must return
FALSE so the entry gets the event as well
Aborted

trunk_64> bzr revno
9870

Revision history for this message
su_v (suv-lp) wrote :

Reproduced with Inkscape 0.48 r9654 and 0.48+devel r9870 on OS X 10.5.8,
not reproduced with Inkscape 0.47.

Duplicate of Bug #665316 “crash when saving after changing stroke width (no focus-out-event)”?
<https://bugs.launchpad.net/inkscape/+bug/665316>

The trigger seems changing the stroke width in the 'Fill&Stroke > Stroke style' tab using the mouse scroll wheel without actually clicking in the widget (entry field) first.

tags: added: cash regression
Changed in inkscape:
importance: Undecided → High
status: New → Confirmed
Revision history for this message
su_v (suv-lp) wrote :

console messages (crash with 0.48+devel r9870):

**
ERROR:document-undo.cpp:172:void sp_document_maybe_done(SPDocument*, const gchar*, unsigned int, Glib::ustring): assertion failed: (doc->priv->sensitive)

Emergency save activated!

Emergency save document locations:
  /Users/suv/New document 1.2010_11_01_18_16_21.0.svg
Emergency save completed. Inkscape will close now.
If you can reproduce this crash, please file a bug at www.inkscape.org
with a detailed description of the steps leading to the crash, so we can fix it.

(inkscape-bin:35476): Gtk-WARNING **: GtkEntry - did not receive focus-out-event. If you
connect a handler to this signal, it must return
FALSE so the entry gets the event as well

Revision history for this message
su_v (suv-lp) wrote :

Also happens when changing opacity in the Fill&Stroke dialog using the mouse wheel only: clicking on a button in the snap controls bar without returning the focus to the canvas first lets Inkscape crash (doesn't matter which tool is active).

su_v (suv-lp)
summary: - crash when activating "snap to path" mode
+ crash when activating "snap to path" mode after changing stroke width
+ (no focus-out-event)
su_v (suv-lp)
tags: added: ui
Revision history for this message
su_v (suv-lp) wrote :

attaching somewhat better backtrace (using gdb).

Revision history for this message
Adonis Papaderos (ado-papas) wrote :

It seems that toggling the snap to path fires a modified events, calling the sp_stroke_style_line_selection_modified handler. The handler rereads the width value of the spinbutton (changed either because of precision problems or late call of the focus-out event) and sets spinbutton adjustment value. This fires a modification event from the spinbutton that tries to commit the change in the undo history resulting in the crash because the current action in the document is snap to path, that is undoable. The following patch could be used as a workaround, although I am not sure if it is the best way of fixing this.

=== modified file 'src/widgets/stroke-style.cpp'
--- src/widgets/stroke-style.cpp 2010-08-22 19:33:18 +0000
+++ src/widgets/stroke-style.cpp 2010-11-11 09:53:31 +0000
@@ -1200,7 +1200,7 @@
     sp_repr_css_attr_unref(css);
     css = 0;

- sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE,
+ if (sp_document_get_undo_sensitive(document)) sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE,
                      _("Set stroke style"));

     spw->set_data("update", GINT_TO_POINTER(FALSE));

Revision history for this message
su_v (suv-lp) wrote :

@Adonis Papaderos
When testing for the related (or same) Bug #665316 “crash when saving after changing stroke width (no focus-out-event)” [1] with older revisions, it turned out that the bug was introduced between r8854 and r8865 (of inkscape trunk). I haven't repeated those tests with the 'steps to reproduce' in this report (bug #669537), but can do to confirm the regression if needed.

Maybe this helps for finding / evaluating a solution. Possibly the regression was introduced by the new code for the connector tool that was merged at that time.

[1] <https://bugs.launchpad.net/inkscape/+bug/665316> comment #4

Revision history for this message
Adonis Papaderos (ado-papas) wrote :

After more investigation it turns out that the code that actually emits the focus out event to the spinbutton was introduced with revision 8855 in file src/widgets/toolbox.cpp

prev version:
static void connector_tb_event_attr_changed(Inkscape::XML::Node *repr,
                                            gchar const *name, gchar const * /*old_value*/, gchar const * /*new_value*/,
                                            bool /*is_interactive*/, gpointer data)
{
    GtkWidget *tbl = GTK_WIDGET(data);

    if (g_object_get_data(G_OBJECT(tbl), "freeze")) {
        return;
    }
    if (strcmp(name, "inkscape:connector-spacing") != 0) {
        return;
    }

    GtkAdjustment *adj = (GtkAdjustment*)
            gtk_object_get_data(GTK_OBJECT(tbl), "spacing");
    gdouble spacing = defaultConnSpacing;
    sp_repr_get_double(repr, "inkscape:connector-spacing", &spacing);

    gtk_adjustment_set_value(adj, spacing);
    gtk_adjustment_value_changed(adj);

    spinbutton_defocus(GTK_OBJECT(tbl));
}

new version:

static void connector_tb_event_attr_changed(Inkscape::XML::Node *repr,
                                            gchar const *name, gchar const * /*old_value*/, gchar const * /*new_value*/,
                                            bool /*is_interactive*/, gpointer data)
{
    GtkWidget *tbl = GTK_WIDGET(data);

    if (g_object_get_data(G_OBJECT(tbl), "freeze")) {
        return;
    }
    if (strcmp(name, "inkscape:connector-spacing") == 0)
    {
        GtkAdjustment *adj = (GtkAdjustment*)
                gtk_object_get_data(GTK_OBJECT(tbl), "spacing");
        gdouble spacing = defaultConnSpacing;
        sp_repr_get_double(repr, "inkscape:connector-spacing", &spacing);

        gtk_adjustment_set_value(adj, spacing);
        gtk_adjustment_value_changed(adj);
    }

    spinbutton_defocus(GTK_OBJECT(tbl));
}

but I cannot figure out why this change was made. If there is no reason for this maybe we could revert it?

Revision history for this message
Adonis Papaderos (ado-papas) wrote :

patch for reverting the aforementioned function.

Revision history for this message
su_v (suv-lp) wrote :

@Michael - subscribing you to this bug: any chance you can review the patch in comment #8? It reverts a change that was merged with the new GSoC Connectors in r8855, in 'src/widgets/toolbox.cpp':
<http://bazaar.launchpad.net/~inkscape.dev/inkscape/trunk/revision/8855#src/widgets/toolbox.cpp>

Could this small piece of code be reverted without breaking any connector features (rerouting, auto-spacing)?

Revision history for this message
Adonis Papaderos (ado-papas) wrote :

Thanks ~suv for your help

Revision history for this message
su_v (suv-lp) wrote :

Patch tested with Inkscape 0.48+devel r9890 on OS X 10.5.8:
crash as described in bug #665316 and bug #669537 no longer reproduced, but I cannot confirm for sure that it has no unintended side-effects for the connectors.

Changed in inkscape:
milestone: none → 0.48.1
status: Confirmed → Fix Committed
Revision history for this message
jazzynico (jazzynico) wrote :

Trunk, revision 9923,
0.48.x, revision 9734.

Changed in inkscape:
assignee: nobody → Adonis Papaderos (ado-papas)
tags: added: crash
removed: cash
Revision history for this message
Pedro Lopes (pedro-lopes) wrote :

Also this happens to me on save-as, while the panel of the stroke is opened and the object is selected. Report:

If the dialog/panel of the strokes is opened and I hit ctrl-s (save as) it will always crash inkscape.
Operating system: Ubuntu 10.10 32bits Maverick Meerkat
Linux version 2.6.35-23-generic-pae (buildd@roseapple) (gcc version 4.4.5 (Ubuntu/Linaro 4.4.4-14ubuntu5) ) #41-Ubuntu SMP Wed Nov 24 10:35:46 UTC 2010

Version of inkscape:
Inkscape 0.48.0 r9654 (Feb 15 2011)

jazzynico (jazzynico)
Changed in inkscape:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.