develooper Front page | perl.perl5.porters | Postings from November 2003

Re: need your help to do some (simple?) patching

Thread Previous | Thread Next
From:
Jan Dubois
Date:
November 17, 2003 02:19
Subject:
Re: need your help to do some (simple?) patching
Message ID:
jo5hrvs2job9tt61ik30ccccj4dmi5ft4c@4ax.com
On Mon, 17 Nov 2003 09:09:32 +0000, Nick Ing-Simmons
<nick.ing-simmons@elixent.com> wrote:

>>XS modules already don't have to call PERL_SET_CONTEXT at all if you write
>>them correctly (using PERL_NO_GET_CONTEXT, passing the context explicitly
>>to pure C functions).  Maybe this information should be published more
>>prominently so that new modules take advantage of that.
>
>It is a pain to upgrade a complex XS to PERL_NO_GET_CONTEXT style,
>but it should be encouraged.
>
>Tk has problems in that callbacks need to get an aTHX from somewhere.

Can't you allocate additional per-window memory with cbWndExtra in your
RegisterClass call, and then store the context in there using
SetWindowLongPtr()?

I recognize that this is Windows specific, but at least on Windows it is
not safe to call PERL_GET_CONTEXT from a Window callback.  It is possible
that an embedding application has switched to a different Perl interpreter
and is executing some code that spins the messageloop.  Any message
callbacks will now execute in the wrong interpreter unless the callback
sets/restores the context.

It is probably an uncommon scenario, but I've seen it happen in the past
(not with Tk though).

Cheers,
-Jan


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About