warning or crash when removing widgets from box
- From: Stephen Tell <tell cs unc edu>
- To: GTK Mailing List <gtk-list redhat com>
- Subject: warning or crash when removing widgets from box
- Date: Mon, 14 Sep 1998 17:55:01 -0400 (EDT)
(Please forgive me if this has been seen - I tried posting this to
gtk-list about two weeks ago, and haven't seen the question or any
responses come through.)
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
operations.
To remove a button, I simply destroy it:
gtk_widget_destroy(vw->button);
My understanding is that gdk_widget_destroy detaches the button from its
parent container, and then cleans it up. I thought the above was right,
based on an older posting to the gtk-list.
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);
gtk_widget_show(vw->label);
gtk_widget_show(vw->button);
elsewhere (earlier) in the code, the box is set up like this:
wp->lvbox = gtk_vbox_new(FALSE, 0);
gtk_widget_show(wp->lvbox);
gtk_table_attach(GTK_TABLE(wtable->table), wp->lvbox,
0, 1, i, i+1,
GTK_FILL, GTK_EXPAND|GTK_FILL, 4, 0);
Thanks!
Steve
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]