From: John L. <jla...@gm...> - 2012-09-17 23:26:58
|
On Mon, Sep 17, 2012 at 6:15 AM, Victor Bombi <so...@te...> wrote: > > Thank you for answering. I have solved the problems in my lualanes and wx > application. It seems that something is not working if I do > require"something" inside a lane that has not been required in the lua_state > where wx is loaded. When the lane is finished wx gets hanged (I guess that > when unloading the dll) so I am now requiring everything in the main I have not used LuaLanes, my understanding is that it is a multi-threading library in the true sense, rather than a coroutine that really just timeslices the main thread. If this is the case, then you absolutely cannot call wxWidgets GUI functions from any other thread than the main thread. If this has "worked" for you in the past, consider yourself very lucky, you should have no expectation that it will continue to work. Please read this for a better understanding, only wxEvtHander::AddPendingEvent() is safe from worker threads. http://docs.wxwidgets.org/trunk/overview_thread.html > lua_state even if I dont need it. Another problem came from wx defining bit > instead of wx.bit so when I use bit from luaBitOp lanes get confused also (I > renamed it bitOp for solving). This is by design, when wxLua moves to 5.2, the bit library we install will be removed and nobody should notice. Is there any difference between luaBitOp and the one wxLua provides? > I have always wanted to require wx in a lane but because of "only once" dll > initialization it does not work. I am able to require wx from a lane if it > has not been required from the "main" lua_State. Do you thing it could be > changed anyhow so that luaopen_wx does not return lua_getglobal(L, "wx");? > Would that break wx? If, and only if, all you want to get at is wxEvtHander::AddPendingEvent() perhaps Lindas will work for you? Again, I've never used LuaLanes, but sending Lindas to the main thread look like they were made for this purpose. On the other hand, if you want to use wxWidgets structures like a wxImage, wxRect, etc, then consider that calling require("wx") takes a fair amount of time itself and it may not be worth creating the thread. Perhaps you can extract the work that needs to be done in pure-Lua structures. Hope this helps, John |