Re: Help: why Gtk::Bin.remove() deletes my object



Hi,

Howard Zhou <howardzzh yahoo com> writes:


> I tried to switch between text object
> in a scrolled window by calling remove() then add(*_)
> because the trial with just calling add(*_) does not
> work. But I found that remove() will actually delete
> the text object I put in first.

the container (scrolled window) takes ownership of the
object you add to it and sinks it. All GTK+ containers
behave like this. You need to change your code to:

  gtk_object_ref (object1);
  container_add (container, object1);
  ...
  container_remove (container, object1);
  container_add (container, object2);

Then don't forget to unref your object as soon as you
don't need it anymore.


Salut, Sven




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