#13 Win32::GUI and PERL_CONTEXT


A contact from ActiveState had this to say about issues
when using Win32::GUI from a .dll created with PerlCtrl.

In case you want to take up the details with the
Win32::GUI developers:
Win32::GUI doesn't properly track the PERL_CONTEXT,
which is essentially a
pointer to the currently active interpreter structure.
When a Window
receives a message, Win32::GUI just assumes that it
can use the currently
"selected" Perl interpreter (and that there even is one).

The sequence of events when using Win32::GUI from a
PerlCtrl is something
like this:

* PerlCtrl saves old PERL_CONTEXT (probably not
pointing anywhere)
* PerlCtrl sets context to embedded Perl interpreter
* PerlCtrl calls Perl method
* Perl method creates Win32::GUI window and calls
* User clicks "Cancel" button and Win32::GUI::Dialog()
* Perl method returns
* PerlCtrl restores old (potentially meaningless)
* PerlCtrl returns to VB
* Windows dispatches another message to the
Win32::GUI window
GUI_MessageLoops.cpp, WindowMsgLoop() function
message was WM_SETCURSOR during my testing
* Win32::GUI now prepares to call back into Perl using
the ENTER macro
which crashes as the current PERL_CONTEXT is not

It looks like Win32::GUI does some kind of context
tracking in the
PERL_OBJECT case, but that code is for Perl 5.005
only. It needs to do
something similar for 5.6 and 5.8 too if you want to use
it from embedded
Perl interpreters.

At the very least, it should *not* dispatch messages
anymore after
Win32::GUI::Dialog() has already returned.


  • Rocher Laurent

    Rocher Laurent - 2004-03-27

    Logged In: YES

    I add PERL_CONTEXT tracking for 5.8 and 5.6 in new base
    code ( MAIN CVS branch ).

  • Rocher Laurent

    Rocher Laurent - 2004-03-27
    • assigned_to: nobody --> lrocher
    • status: open --> closed-fixed

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks