warning/crash removing widgets from box

In an application I'm writing using Gtk+ (Gtk+ 1.0.4, currently)
I have a GtkVBox that is to contain zero or more GtkToggleButtons,
which are added and removed from the box according to other user-interface

To remove a button, I have tried either or both of these statements (in
this order, if both are present):
	gtk_container_remove(GTK_CONTAINER(wp->lvbox), vw->button);

I thought the above was right, based on a real old posting to the

Whatever I try, when running on HP-UX, I get a lot of runtime warnings
messages of this form but the button does disappear:
** WARNING **: invalid cast from `GtkButton' to `GtkToggleButton'
** WARNING **: invalid cast from `(unknown)' to `GtkToggleButton'
** WARNING **: invalid cast from `(unknown)' to `GtkToggleButton'
** WARNING **: invalid cast from `(unknown)' to `GtkToggleButton'
** WARNING **: invalid cast from `(unknown)' to `GtkToggleButton'
** WARNING **: invalid cast from `(unknown)' to `GtkToggleButton'

On Linux I usually get a SIGSEGV, after one or two runtime warnings:
** WARNING **: invalid cast from `GtkButton' to `GtkToggleButton'
** WARNING **: file gtkcontainer.c: line 359 (gtk_container_remove):
"widget->parent == GTK_WIDGET (container)"
** ERROR **: sigsegv caught

Adding buttons I do like this, which seems to work fine.  I'm explicitly
creating the label for the button so I can keep a pointer to it for use in
changing the label's text.

	vw->label = gtk_label_new(lbuf);
	vw->button = gtk_toggle_button_new();
	gtk_container_add(GTK_CONTAINER(vw->button), vw->label);
	gtk_box_pack_start(GTK_BOX(wp->lvbox), vw->button,
			   FALSE, FALSE, 0);
	sprintf(lbuf, "wavecolor%d", vw->colorn);
	gtk_widget_set_name(vw->label, lbuf);

elsewhere in the code, the box is set up like this:

		wp->lvbox = gtk_vbox_new(FALSE, 0);
		gtk_table_attach(GTK_TABLE(wtable->table), wp->lvbox, 
			 0, 1, i, i+1, 


The application is a waveform viewer for analog data, say from spice
simulation.  I've thrown a copy into
http://www.cs.unc.edu/~tell/dist/gwave.tar.gz in case anyone wants to look
at the whole thing. 

Steve Tell | tell@cs.unc.edu | http://www.cs.unc.edu/~tell | KF4ZPF
Research Associate, Microelectronic Systems Laboratory
Computer Science Department, UNC@Chapel Hill.   W:919-962-1845

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