Re: Is widget destroy automagic or not ?




Alexandre Jousset said:
      This may seem an obvious thing but I can't figure if widgets, in
Gtk2-Perl, are garbage collected by Perl or not. Must I destroy them
explicitly after use or not ?

gtk+ itself holds a reference on toplevel windows, so simply letting them go
out of scope does not allow their reference counts to fall to 0.  you must
call $window->destroy explicitly to destroy the gui object and remove that
reference.

for all other widgets, the reference-counting is "normal".  after you add it
to a container, it is owned by the container; until then, just letting the
object go out of scope will be enough to destroy it.

recall that widgets cannot be seen unless they have been added to a toplevel
window.  thus, $toplevel->destroy should clean up all of the widgets inside
it.


please note i am waving my hands wildly during all of this.  the details are
rather devilish.

-- 
muppet <scott at asofyet dot org>



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