Re: Please: Explain what happens when on use gtk_container_remove



> From: Preben Randhol <randhol pvv org>
> Hi
>
> I do this (note the code is not in C as I use Ada 95, but it should be
> understandable)
>
>    Gtk.Container.Add (Some_Vbox, Some_Frame);
>    Gtk.Container.Remove (Some_Vbox, Some_Frame);
>    Gtk.Container.Add (Some_Vbox, Some_Frame);
>
> As I understand the documentations the Remove should not alter the
> Some_Frame widget, but at the second Add I get:
>
>  Gtk-CRITICAL **: file gtkcontainer.c: line 714 (gtk_container_add):
>  assertion `GTK_IS_WIDGET (widget)' failed.  
>

You probably need to do a gtk_object_ref() (or the equivalent
in the Ada wrapper) before you remove the widget. When you
add the frame to the vbox, its floating reference is removed
after it is refed by the vbox. When you remove it, it is unrefed,
and destroyed if its ref count is zero. If you ref it before this
sequence of actions and unref it afterward, things should be fine.

					Ron Steinke




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