Re: Wierd error when activating an Entry

Alex Ward said:
I was getting this when using the old 0.12 lib so I moved to 0.22 but it is
still the same.  I'm guessing I'm just doing something wrong.

nope, not you.  fixed in CVS.

it happened in both 0.12 and 0.22 because gtk2-perl-xs inherited some very
important code from gtk2-perl, namely signal, closure, and value handling.

the bug was the assumption that if a closure is defined to have no return
type, then there will be no GValue pointer to receive the return value passed
to the marshaller.  apparently, this is not true, though it seems to be valid
in general.

whatever code (within gtk itself, not the bindings) invokes the activated
closure on GtkEntry ignores the fact that there is no return value and passes
a GValue with type set to 0 (G_TYPE_NONE).  the glib-perl code which marshals
the callbacks saw that there was a GValue pointer and called the function in
scalar context, and then passed that scalar and the GValue to
gperl_value_from_sv... only to have gperl_value_from_sv complain that the
GValue has no type.

the correct solution was to make sure that the return value holder has a type
before going into the branch that keeps return values.

    $new_query_name_entry->signal_connect(activate => sub { print
"clicked\n"; 1});

incidentally, the "1" at the end of your callback is not necessary, because
the "activate" signal has a return type of (void).

muppet <scott at asofyet dot org>

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