Problem with GtkCombo and dynamic drop-down lists



If the following program is compiled (gcc 2.95.2 on SuSE 6.3, glib 1.2.7
and gtk 1.2.7) with:

gcc `gtk-config --cflags --libs` gtkcombocrash.c -o gtkcombocrash

And then run with ./gtkcombocrash you can generate a Segmentation fault
in gtk_container_set_focus_child routine.

If the program runs, chose with the mouse the pulldown menu then chose
with the MOUSE the third item (The pulldown disapears). Then push the
delete button. Next chose with the mouse the arrow to make the pulldown
menu appear and then use the ARROW_DOWN - KEY of your *keyboard*.

On my machine this results in a Segmentation fault .

What in my usage of GtkCombo is wrong.

tobias


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void del_cli(GtkButton * button, gpointer data){
        GtkWidget       * combo;
        gchar                   * text;
        GList *items = NULL;
        gint                    i;
        /* 
                Get active item 
        */
        combo   =       (GtkWidget      *)data;
        text    =       gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry));
        for (i=0;i<5;i++){
                if (g_strcasecmp(text,itemlist[i])){
                        items = g_list_append (items, itemlist[i]);
                }
        }
        gtk_combo_set_popdown_strings (GTK_COMBO (combo), items);
}
int main(gint argc, gchar * argv[]){
        GtkWidget       * window;
        GtkWidget       * combo;
        GtkWidget       * vbox;
        GtkWidget       * button;
        GList   *items = NULL;
        gint                    i;

        gtk_init(&argc,&argv);
        window  =       gtk_window_new(GTK_WINDOW_TOPLEVEL);

gtk_signal_connect(GTK_OBJECT(window),"destroy",GTK_SIGNAL_FUNC(gtk_main_quit),NULL);
        
        vbox    =       gtk_hbox_new(TRUE,0);
        gtk_container_add(GTK_CONTAINER(window),vbox);
        
        for (i=0;i<5;i++){
                items = g_list_append (items, itemlist[i]);
        }

        combo = gtk_combo_new();
        gtk_combo_set_popdown_strings (GTK_COMBO (combo), items);
        gtk_box_pack_start(GTK_BOX(vbox),combo,FALSE,TRUE,0);
        gtk_widget_show(combo);
        
        button  =       gtk_button_new_with_label("Delete");
        gtk_box_pack_start(GTK_BOX(vbox),button,FALSE,TRUE,0);

gtk_signal_connect(GTK_OBJECT(button),"clicked",GTK_SIGNAL_FUNC(del_cli),combo);
        gtk_widget_show(button);
        
        
        gtk_widget_show_all(window);
        gtk_main();
        return(TRUE);
}




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