-
Notifications
You must be signed in to change notification settings - Fork 80
Segfault when linking Scale widget with Entry #161
Comments
Oh, and here's the backtrace:
|
I wanted to check that I wasn't missing something, so here's a comparison C program (no segfault): #include <gtk/gtk.h>
#include <stdio.h>
char lbl[255] = "howdy";
void set_entry(GtkWidget *widget, gpointer data)
{
GtkAdjustment *adj;
GtkEntry *entry;
double val;
char *lbl;
adj = gtk_range_get_adjustment((GtkRange*) widget);
val = gtk_adjustment_get_value(adj);
sprintf(lbl, "%g", val);
entry = (GtkEntry*) data;
gtk_entry_set_text(entry, lbl);
}
int main(int argc, char *argv[])
{
GtkWidget *window;
GtkWidget *entry;
GtkWidget *scale;
GtkBox *vbox;
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
vbox = (GtkBox*) gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
entry = gtk_entry_new();
scale = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, 0, 10, 1);
gtk_entry_set_text((GtkEntry*)entry, lbl);
gtk_container_add(GTK_CONTAINER(window), (GtkWidget*)vbox);
gtk_box_pack_start(vbox, entry, FALSE, FALSE, 10);
gtk_box_pack_start(vbox, scale, FALSE, FALSE, 10);
g_signal_connect(window, "delete-event", G_CALLBACK (gtk_main_quit),
NULL);
g_signal_connect(scale, "value-changed", G_CALLBACK (set_entry), entry);
gtk_widget_show_all(window);
gtk_main();
return 0;
} |
No segfault if I use the more low-level approach: function value_changed_cb(ptr::Ptr, entry)
sc = convert(Scale, ptr)
val = G_.value(sc)
setproperty!(entry, :text, string(val))
nothing
end
signal_connect(value_changed_cb, sc, "value-changed", Void, (), false, e) |
this is most likely an issue with the julia option COPY_STACKS corrupting the stack. it looks like another redesign of the gtk callback handling may be in my future to work around that. |
Joy joy. Meanwhile, no rush since I figured out a workaround that I'm quite content with. |
While I think the real solution to this will be to merge #13099, I think a temporary solution would be to remove the g_siginterruptible from https://github.com/JuliaLang/Gtk.jl/blob/40f7442dea20919c5a7b137594fb6d7636fa2329/src/GLib/signals.jl#L91 and just avoid calling yield / print / async from inside any Gtk callback. |
what high-level Gtk functions call yield / print / async? i'd really like to upgrade my code from julia 0.3 to 0.4 and need to know more specifically what to avoid in callbacks. can i |
I encountered a similar problem when setproperty! is used within a signal handler... The following code consistently crashes when I press a key:
I don't know if this is the same issue. Just letting you know. MA |
The workaround in #161 (comment) is not sufficient; I tried it and still needed JuliaGtk/GtkUtilities.jl#7 to fix a segfault. |
If I move the scale slowly, this works as intended. However, quick movement---or any movement, if I delete the
@schedule
---causes a segfault for me:I also get the segfault if I use
G_.value(sc)
rather thangetproperty
.The text was updated successfully, but these errors were encountered: