Re: gperl_callback_invoke userdata copy
- From: Torsten Schoenfeld <kaffeetisch gmx de>
- To: gtk-perl-list gnome org
- Subject: Re: gperl_callback_invoke userdata copy
- Date: Tue, 16 Sep 2008 21:24:19 +0200
Kevin Ryde wrote:
Maybe something like this to describe the userdata scalar.
Though I guess it belongs somewhere in Glib rather than Gtk.
I think it's fine to have it in Gtk2. A few comments:
on a possibly localized error message; you can match errors by explicit and
predictable conditions. See L<Glib::Error> for more information.
Use normal perl callback/closure tricks with callbacks. The most common use
you'll have for callbacks is with the Glib signal_connect method:
This makes "Callbacks" come after "Miscellaneous". I think it would be better
to move the callback stuff above "Miscellaneous".
+The userdata is copied from the value you supply in signal_connect, so
+it's a separate scalar and modifying it doesn't modify a variable etc
+you might have passed to signal_connect. The copy is "shallow", the
+same as a plain assignment like
+ my $stored_user_data = $initial_user_data;
+ &$callback (..., $stored_user_data);
+ # ... $_[-1] alters $stored_user_data, not $initial_user_data
This confuses me. The paragraph above the code seems to say that altering
$_[-1] does *not* modify the variable passed to signal_connect() -- but the
point of this thread has been to guarantee that it does, right?
] [Thread Prev