On Mon, Oct 27, 2014 at 8:03 AM, Victor Bombi <son...@telefonica.net> wrote:

> Hello,
>
> this is related to something we talked before in the list.
>
> In order to require"wx" from two diferent lanes in luaLanes I modified
> luamodule.cpp:
>  instead of static wxLuaState s_wxlState; I have  wxLuaState* s_wxlState =
> new wxLuaState; inside luaopen_wx so that we get a different wxLuaState in
> each lane.
>
> In each lane a wxFrame is created and wxGetApp():MainLoop() is called at
> the
> end of the function used as the lane body.
> The first lane that calls wxGetApp():MainLoop() succeds but the second one
> fails because IsMainLoopRunning is true (as it is refering the same
> instance) and this lane ends.
>
> The main problem I see is that there is only one wxApp created by wxWidgets
> so it is not possible to have two independent message loops. (and maybe two
> independent wxApps)
>
> Is there something that can be done to create two different wxApp one in
> each lane?
>
>
I'm pretty sure that having two separate wxApps in the same application is
not supported by wxWidgets. Doing anything with a GUI widget from different
threads at the same time is definitely not supported by any underlying GUI
framework that wxWidgets uses; MSW, GTK, OSX, etc.

The standard practice is to create the GUI in one and only one thread
(doesn't have to be main, but typically is) and then use
wxEvtHandler::QueueEvent(wx.wxCommandEvent(...)) to post messages from any
other thread to the GUI thread. Basically, you connect your app to an
arbitrary event type, wxEVT_COMMAND_BUTTON_CLICKED for example, with a
unique ID and pass your data through the wxCommandEvent's
Get/SetString/Int() etc. You may want to use lanes to do this message
passing between threads if you like or if it's possible.

The bottom line, I really don't think creating two wxApps in a single
process is ever going to work even if the wxLua side was made thread-safe.
It would be incredibly fragile.

Regards,
    John
------------------------------------------------------------------------------
_______________________________________________
wxlua-users mailing list
wxlua-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxlua-users

Reply via email to