Re: gtk2-perl / a script to help converting basic functions
- From: muppet <scott asofyet org>
- To: gtk-perl-list gnome org
- Subject: Re: gtk2-perl / a script to help converting basic functions
- Date: Sun, 27 Oct 2002 14:56:02 -0500
Guillaume Cottenceau wrote:
>goran kirra net writes:
>
>
>
>>It may be bad style to code thtat way but I don't think I like
>>the supprise of the window disappearing when a perl variable get
>>garbage collected.
>>
>>
>
>In my opinion, this is little surprise the first time you see it,
>but good feature in the long term. And after all, since you lost
>the last reference to $window, you won't be able to destroy or
>hide this window forever.. and that is not what I consider a good
>programming feature.
>
>But anyway if all people are against that, of course..
>
it's more involved than that.
you can get pointers to windows from many many places. if you have a
widget, you can get a pointer to its toplevel window. you get a pointer
to a window in any event handler invoked on that window. you don't
actually *need* to keep the toplevel window's pointer around.
even worse, making the perl DESTROY destroy a window can make the
windows be destroyed at bizarre times.
suppose you bother to keep around a perl ref to a toplevel window. at
some point later, you do this:
sub {
my $toplevel = $somewidget->get_toplevel;
....
}
at the end of that sub, the toplevel window will be destroyed, because a
perl ref to a Gtk::Window has gone out of scope and been flagged for GC.
now again, i suppose you could make a distinction between pointers
coming from constructors and from other functions, but then the magic
begins to turn black, as it is now inconsistent.
Gtk already gives you complete and explicit control over the lifetimes
of widgets. there is no reason to destroy this, so that people have to
learn a completely different way to handle Gtk in perl than anywhere else.
my vote is firmly against auto destroy of widgets/windows from the perl
DESTROY. DESTROY should unref the GObject ref taken when the perl var
was created. let the Gtk programmer have the control he expects to have.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]