Z
zombek
Hello.
I wrote a simple GTK+ program. On clicking a button I use calculate_cb
callback function, and send MainWindow structure (it contains widgets)
as data. When inside the callback function I try to assign
gtk_editable_get_chars(GTK_EDITABLE(main_window->a_entry), 0, -1) to s
I get segmentation fault.
Could anyone help me in finding the bug.
Parts of the code:
void calculate_cb(GtkWidget *widget, GdkEvent *event, MainWindow
*main_window)
{
/* ... */
gchar *s;
s = (gchar *)g_malloc((ENTRY_MAX_LEN + 1) * sizeof(gchar));
s = gtk_editable_get_chars(GTK_EDITABLE(main_window->a_entry),
0, -1);
/* ... */
}
/* ... other file ...*/
g_signal_connect(G_OBJECT(main_window->calc_btn), "clicked",
G_CALLBACK(calculate_cb), main_window);
*/ ... */
I wrote a simple GTK+ program. On clicking a button I use calculate_cb
callback function, and send MainWindow structure (it contains widgets)
as data. When inside the callback function I try to assign
gtk_editable_get_chars(GTK_EDITABLE(main_window->a_entry), 0, -1) to s
I get segmentation fault.
Could anyone help me in finding the bug.
Parts of the code:
void calculate_cb(GtkWidget *widget, GdkEvent *event, MainWindow
*main_window)
{
/* ... */
gchar *s;
s = (gchar *)g_malloc((ENTRY_MAX_LEN + 1) * sizeof(gchar));
s = gtk_editable_get_chars(GTK_EDITABLE(main_window->a_entry),
0, -1);
/* ... */
}
/* ... other file ...*/
g_signal_connect(G_OBJECT(main_window->calc_btn), "clicked",
G_CALLBACK(calculate_cb), main_window);
*/ ... */