Re: gtk2-perl / a script to help converting basic functions
- From: Daniel Lacroix <dlacroix erasme org>
- To: Guillaume Cottenceau <gc mandrakesoft com>
- Cc: goran kirra net, gtk-perl-list gnome org
- Subject: Re: gtk2-perl / a script to help converting basic functions
- Date: 25 Oct 2002 18:24:27 +0200
Le ven 25/10/2002 à 17:11, Guillaume Cottenceau a écrit :
Daniel Lacroix <dlacroix erasme org> writes:
I find all thoses problems stranges. For me, when a user create a Gtk
object, he must destroy it. When object is packed into another object
you only have to destroy the root object. So the Gtk way of doing things
is sufficent.
With current gtk-perl, when perl destroys a Gtk::Window, it
automatically destroys the "actual" gtk window on the GUI. I like
this feature, it's logical and useful (because it's a toplevel
widget). If we do what you suggest, then we'd need to call
$window->destroy at the user level just before perl destroys the
Gtk::Window. This is another possibility, it's possible, but I
personally don't like it, I prefer it inside gtk2-perl, it's more
clean and more logical for the gtk2-perl users IMHO.
I don't thing that it is unlogical. If the programmer want at a time
close it's window, he will call destroy and not doing $window=undef;
and normally it is the user who close the window by clicking on it and
you don't have to call destroy in your code. You just let it die.
There is really no need to keep the perl variable in the same state as
the real pointer un Gtk. If you want to keep your perl variable coherent
why not connect to destroy event of each widget and undef the
corresponding perl variable. This is absolutely not needed.
Also, don't forget the problem of destructing structs (GdkColor
etc) which we explicetely malloc. We need to free them, gtk won't
do that of course, since it doesn't even know about it except
when these structs are used to pass information to functions.
For struct like GdkColor, you don't have to malloc in C and keep the
pointer. Perhaps that a better solution will be to have a perl hash
table and only convert for the perl href to C struct when using it in C
and free after use. So GdkColor struct will exist only in the C wrapper
function the time of the function. I think that it exist only few case
where we need to malloc and keep a C pointer in perl but have not really
studie Gtk2.
Daniel
[...]
If you create such an object and don't use it for a widget then you have
to use the unref funtion of all GObject.
But using a DESTROY with unref on it is dangereous because those object
can be use by other part of Gtk while no more accessible by Perl.
Yep that was my preferred point when discussing about the GObject
hierarchy (point '2').
--
Guillaume Cottenceau - http://people.mandrakesoft.com/~gc/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]