GTK_ENTRY cast segfaults, I think



Hello.

I have a window that has several GtkEntry widgets.  I store pointers to
those widgets in a GList, and attach the Glist as object data with
gtk_set_object_data.  When the callback funtion for the "Okay" button is
clicked, a callback funtion is called that gets the GList from the
widget data and goes through each element, storing the text in the entry
widgets pointed to by the data in the GList.  However, I get a
segmentation fault whenever I click "Okay". gdb says:

(gdb) backtrace
#0  0x400fae10 in gtk_type_check_object_cast ()
#1  0x804dbcb in register_new_conn (widget=0x8078fb0, event=0x0, 
    data=0x40137018) at callbacks.c:58
#2  0x400a7b4d in gtk_marshal_NONE__NONE ()
#3  0x400d4fdd in gtk_handlers_run ()
#4  0x400d4422 in gtk_signal_real_emit ()
#5  0x400d2575 in gtk_signal_emit ()
#6  0x401078c8 in gtk_widget_activate ()
#7  0x4010ee24 in gtk_window_key_press_event ()
#8  0x400a7719 in gtk_marshal_BOOL__POINTER ()
#9  0x400d445b in gtk_signal_real_emit ()
#10 0x400d2575 in gtk_signal_emit ()
#11 0x4010777c in gtk_widget_event ()
#12 0x400a75f6 in gtk_propagate_event ()
#13 0x400a68ca in gtk_main_do_event ()
#14 0x4015100b in gdk_event_dispatch ()
#15 0x4017fbe6 in g_main_dispatch ()
#16 0x401801a1 in g_main_iterate ()
#17 0x40180341 in g_main_run ()
#18 0x400a6209 in gtk_main ()
#19 0x804a477 in main (argc=1, argv=0xbffffbf4) at main.c:51
#20 0x4029ecb3 in __libc_start_main (main=0x804a410 <main>, argc=1, 
    argv=0xbffffbf4, init=0x8049ca8 <_init>, fini=0x804e1cc <_fini>, 
    rtld_fini=0x4000a350 <_dl_fini>, stack_end=0xbffffbec)
    at ../sysdeps/generic/libc-start.c:78

And here is a brief portion of the code:

	GtkWidget * entry_temp;
	GList * list;

	list = (GList *)gtk_object_get_data(GTK_OBJECT(widget), "entries");
	
        input_info = (struct conn_info *)malloc(sizeof(info_database));
        bzero(input_info, sizeof(info_database));
        
        entry_temp = (GtkWidget *)g_list_nth_data(list, 0);
/* line 58 */ g_print("%s\n", gtk_entry_get_text(GTK_ENTRY(entry_temp));

Do I need to allocate memory for entry_temp?  The fault seems to occur
in the GTK_ENTRY macro, which is why I think this.

Any insight will be greatly appreciated.  If you need more code, let me
know.

Thanks in advance,

Ron Martin
rmartin@cps.cmich.edu



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]