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, -JanThread Previous | Thread Next