Re: [gtk-list] Very odd segfault



jay wrote:
> 
> Never seen anything like this before... here are a few snips of code, and
> the message I'm getting from gdb.
> 
> typedef struct {
>         GtkWidget *d_area; /* drawing area */
>         GtkWidget *ent;
> } Darea;
> 
> struct {
>         GtkWidget *entry1;
>                         2;
>         ......etc
> } mystruct;
> 
> calling_func(mystruct.entry1, &vbox);
> 
> void calling_func (GtkWidget *entry, GtkWidget **box)
> {
>         GtkWidget *frame;
>         Darea *da_en;

Do you really want a pointer to the structure, or an actual structure.
If you want a pointer, add

	da_en = malloc(sizeof(da_en));

otherwise lose the '*'

>         frame = gtk_frame_new("framename");
>         entry = gtk_entry_new();
>         set_default_ent(entry); /* sets text in entry with
>                                         gtk_entry_set_text */
>         da_en->ent = (gpointer)entry;

da_en never gets initialized. Either malloc some memory for the
pointer, or don't use a pointer (and change '->' to '.').

>         gtk_container_add(GTK_CONTAINER(frame), da_en->ent);
>         gtk_box_pack_start(GTK_BOX(*box), frame, FALSE, FALSE, 0);/*dies
>                                                                    here*/

Probibly dies because of the pointer problems

>         .....
>         ....
>         ...



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