Segmentation fault in gtk_widget_show_all(gtkGrid);

,

Hi, any help for this error.
I have the next function that is triggered on a thread, I get a segmentation fault in “gtk_widget_show_all(gtkGridChat);”

void *msgReceived(void *args)
{
    g_print("[msgReceived] start\n");
    struct requestStrc *response = args;

    char msg[200] = "";
    strcpy(msg, curUserChatName);
    strcat(msg, ": ");
    strcat(msg, response->content);

    gtk_grid_insert_row(GTK_GRID(gtkGridChat), historyMsg);
    button[historyMsg] = gtk_button_new_with_label(msg);
    gtk_grid_attach(GTK_GRID(gtkGridChat), button[historyMsg], 1, historyMsg, 1, 1);
    gtk_widget_show_all(gtkGridChat);
    historyMsg++;

    return NULL;
}

uh its called on a thread you say? Gtk is not threadsafe (as with every toolkit out there). Just call g_idle_add with a custom callback and do your modifications there.

1 Like

Omg!! you are right, I forgot it.
Thank you @gunibert for your answer.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.