Bug in Radio Buttons



Fantastic job on this toolkit! I am building a web performance test tool

with it. The application is real-time and threaded (POSIX threads) and
it seems to work well with the library as long as the GUI thread remains

separate. Now on with my finding . . .

I finally tracked down a test case that demonstrates a bug.  When a
window is created and destroyed multiple times (>1) that contained a 3
member radio button group, GTK produces a segmentation violation. I am
not knowledgable enough about the toolkit to dig much further into the
toolkit to further diagnose the problem.

A code sample that recreates the problem is included below:

#include <gtk/gtk.h>

void
destroy (GtkWidget * widget, gpointer * data)
{
    gtk_main_quit ();
}

int
main (int argc, char *argv[])
{
    GtkWidget *window;
    GtkWidget *button;
    GtkWidget *label;
    GtkWidget *table;
    GtkWidget *vbox;
    GtkWidget *radio_vbox;
    GtkWidget *frame, *frame_vbox;
    GSList *radio_group;

    gtk_init (&argc, &argv);

    for (;;)
      {
          window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

          gtk_signal_connect (GTK_OBJECT (window), "destroy",
                              GTK_SIGNAL_FUNC (destroy), NULL);

          gtk_container_border_width (GTK_CONTAINER (window), 10);

          vbox = gtk_vbox_new (FALSE, 1);
          gtk_container_border_width (GTK_CONTAINER (vbox), 5);
          gtk_container_add (GTK_CONTAINER (window), vbox);
          gtk_widget_show (vbox);

          radio_vbox = gtk_vbox_new (FALSE, 1);
          gtk_container_border_width (GTK_CONTAINER (radio_vbox), 5);
          gtk_container_add (GTK_CONTAINER (vbox), radio_vbox);
          gtk_widget_show (radio_vbox);
          frame = gtk_frame_new ("Arrival Rate");
          gtk_frame_set_shadow_type (GTK_FRAME (frame),
GTK_SHADOW_ETCHED_IN);
          gtk_box_pack_start (GTK_BOX (radio_vbox), frame, TRUE, TRUE,
0);
          gtk_widget_show (frame);

          frame_vbox = gtk_vbox_new (FALSE, 1);
          gtk_container_border_width (GTK_CONTAINER (frame_vbox), 5);
          gtk_container_add (GTK_CONTAINER (frame), frame_vbox);
          gtk_widget_show (frame_vbox);

          button = gtk_radio_button_new_with_label (NULL, "Log
Synchronize");
          gtk_box_pack_start (GTK_BOX (frame_vbox), button, TRUE, TRUE,
0);
          gtk_widget_show (button);

          radio_group = gtk_radio_button_group (GTK_RADIO_BUTTON
(button));
          button = gtk_radio_button_new_with_label (radio_group,
"Uniform");
          gtk_box_pack_start (GTK_BOX (frame_vbox), button, TRUE, TRUE,
0);
          gtk_widget_show (button);

          /* When the following four lines are commented out, it works
fine */
          button = gtk_radio_button_new_with_label (radio_group,
"Maximum");
          gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (button),
TRUE);
          gtk_box_pack_start (GTK_BOX (frame_vbox), button, TRUE, TRUE,
0);
          gtk_widget_show (button);

          button = gtk_button_new_with_label ("Destroy Window");
          gtk_signal_connect (GTK_OBJECT (button), "clicked",
                               GTK_SIGNAL_FUNC (destroy), NULL);
          gtk_container_add (GTK_CONTAINER (vbox), button);
          gtk_widget_show (button);


          gtk_widget_show (window);
          gtk_main ();
          gtk_widget_destroy(window);
      }


    return 0;
}


I only need hit the "Destroy Window" button twice to generate the
error.  If the last button is commentd out, the scenario works fine.

Can anyone else verify this?

$cott








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