clist (gtk-0.99.3) problem



Hello!

Can somebody explain me why attached program crashes EVERY time I made
second click on "refresh" button.  The error message is 

"** ERROR **: BadPixmap (invalid Pixmap parameter)"

It NEVER crashes if the number of rows is less than 100.

That happens with both GTK-0.99.2 and GTK-0.99.3

-- 
Roman Pozlevich              e-mail: roma@botik.ru
http://www.botik.ru/~roma    phone: +7 (08535) 98044, fax: +7 (08535) 98278
#include <gtk/gtk.h>

#define ROWS	1000


static char * q_xpm[] = {
"17 19 5 1",
" 	c #FFFFFFFFFFFF",
".	c #000000000000",
"X	c #FFFFFBEEFFFF",
"o	c #CF3CCF3CCF3C",
"O	c #861786178617",
"                 ",
"    .X     X.    ",
"  X.         .X  ",
"  .o         o.  ",
"  .           .  ",
" o.           .o ",
" o.           .o ",
" o.o  o...o  o.o ",
"  .O   O.O   O.  ",
"  O.O  O.O  O.O  ",
"  X..OOO.OOO..X  ",
"   o.........o   ",
"    oO.....Oo    ",
"      XO.OX      ",
"       O.O       ",
"       O.O       ",
"       o.o       ",
"        O        ",
"                 "};


static GdkPixmap *q_pix = NULL;
static GdkBitmap *q_pix_mask = NULL;


GtkWidget *clist;


void button_callback (GtkWidget *widget, gpointer data) {
  int i;
  char *row[1] = { "aaa" };

  gtk_clist_freeze (GTK_CLIST (clist));
  gtk_clist_clear (GTK_CLIST (clist));

  for (i = 0; i < ROWS; i++) {
    gtk_clist_append (GTK_CLIST (clist), row);
    gtk_clist_set_pixtext (GTK_CLIST (clist), i, 0, row[0], 4, q_pix, q_pix_mask);
  }

  gtk_clist_thaw (GTK_CLIST (clist));
}


void create_main_window (void) {
  GtkWidget *main_window;
  GtkWidget *vbox;
  GtkWidget *button;

  main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_signal_connect (GTK_OBJECT (main_window), "delete_event",
		      GTK_SIGNAL_FUNC (gtk_true), NULL);
  gtk_signal_connect (GTK_OBJECT (main_window), "destroy",
		      GTK_SIGNAL_FUNC (gtk_main_quit), NULL);

  vbox = gtk_vbox_new (FALSE, 0);
  gtk_container_add (GTK_CONTAINER (main_window), vbox);

  clist = gtk_clist_new (1);
  gtk_widget_set_usize (GTK_WIDGET (clist), 200, 200);
  gtk_box_pack_start (GTK_BOX (vbox), clist, FALSE, FALSE, 0);
  gtk_widget_show (clist);

  button = gtk_button_new_with_label ("Refresh");
  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 8);
  gtk_signal_connect (GTK_OBJECT (button), "clicked",
		      GTK_SIGNAL_FUNC (button_callback), NULL);
  gtk_widget_show (button);

  gtk_widget_show (vbox);

  gtk_widget_show (main_window);

  q_pix = gdk_pixmap_create_from_xpm_d (
        GTK_CLIST (clist)->clist_window, &q_pix_mask, 
        &main_window->style->white, q_xpm);
}


int main (int argc, char *argv[]) {
  gtk_init (&argc, &argv);

  create_main_window ();
  gtk_main ();

  return 0;
}


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