Re: gtk2-perl / a script to help converting basic functions

muppet <scott asofyet org> writes:


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.

i'm not sure we understand each other. the proposal is here to
make the perl code easier, more readable, more logical. of course
i agree we don't need to keep a pointer around. it's just more
convenient to have that.
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.

there is no black magic in keeping a pool of known gtk objects
and returning back the right perl object if it already exists.
it's how it's done with current perl-gtk.
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.

the problem is not to destroy this. we can of course still call
destroy on the window at any time. the point is to have an
automatic call to destroy when the perl object goes out of scope,
for convenience.

Guillaume Cottenceau -

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