Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


[Help] C + Gtk+

I'm getting a segmentation failure (that's the traduction from spanish tu english)

void callback_main_button_build( GtkObject *object ) {
GtkWidget *frame_build;
GtkWidget *table;
GtkWidget *button_build;
GtkWidget *text_id;
GtkWidget *text_passwd;
GtkWidget *text_name;
GtkWidget *text_place;
GtkWidget *text_keyname;
GtkWidget *label_id;
GtkWidget *label_passwd;
GtkWidget *label_name;
GtkWidget *label_place;
GtkWidget *label_keyname;

table = gtk_table_new(6, 2, FALSE);
label_id = gtk_label_new("ID:");
label_passwd = gtk_label_new("Passwd:");
label_name = gtk_label_new("Name:");
label_place = gtk_label_new("Place:");
label_keyname = gtk_label_new("Keyname:");
text_id = gtk_entry_new();
text_passwd = gtk_entry_new();
text_name = gtk_entry_new();
text_place = gtk_entry_new();
text_keyname = gtk_entry_new();
button_build = gtk_button_new_with_label ("Build");
frame_build = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size(GTK_WINDOW(frame_build), 250, 200);
gtk_window_set_title(GTK_WINDOW(frame_build), "Build Card");
gtk_container_add(GTK_CONTAINER(frame_build), table);
gtk_table_attach_defaults(GTK_TABLE(table), label_id, 0, 1, 0, 1);
gtk_table_attach_defaults(GTK_TABLE(table), text_id, 1, 2, 0, 1);
gtk_table_attach_defaults(GTK_TABLE(table), label_place, 0, 1, 1, 2);
gtk_table_attach_defaults(GTK_TABLE(table), text_place, 1, 2, 1, 2);
gtk_table_attach_defaults(GTK_TABLE(table), label_name, 0, 1, 2, 3);
gtk_table_attach_defaults(GTK_TABLE(table), text_name, 1, 2, 2, 3);
gtk_table_attach_defaults(GTK_TABLE(table), label_passwd, 0, 1, 3, 4);
gtk_table_attach_defaults(GTK_TABLE(table), text_passwd, 1, 2, 3, 4);
gtk_table_attach_defaults(GTK_TABLE(table), label_keyname, 0, 1, 4, 5);
gtk_table_attach_defaults(GTK_TABLE(table), text_keyname, 1, 2, 4, 5);
gtk_table_attach_defaults(GTK_TABLE(table), button_build, 0, 1, 5, 6);

I'm calling this form with this code

[code]gtk_signal_connect(GTK_OBJECT(menu_main_file_build), "activate", GTK_SIGNAL_FUNC(callback_main_button_build), NULL);

It's really strange cause i did it with another form and it worked but, the last two aren't working..


  • Malcolm_McLeanMalcolm_McLean Member Posts: 254 ✭✭
    To solve the problem

    put in a diagnostic printf at the start and at the end of the callback function.

    Is the callback function called, does the program crash before or after it returns?

    If the program crashes between your two points, add further diagnostics until you've narrowed it down. If it crashes afterwards, you've probably corrupted something. If the callback is never called, you're passing something bad to the set up function.

    If all else fails, comment out code until your application is reduced to a "hello world", then comment code back in again until the problem reappears. Then try to isolate what is causing the fault.
  • lautaroxlautarox Member Posts: 3
    Thanks for the recommendations, the error occurs when I press "activate" one menu button, it says "Fallo de segmentacion" in spanish, that's "Segmentation failure" in english, it's really strange cause I have another menu working perfectly, can you give me examples on how to catch some errors?
Sign In or Register to comment.