Quoting Antonio Scuri (2022-05-27 14:02:18) > > Would it be possible to release a new iup version from the latest svn > > master to have this fix available in the official build? > > That depends on the changes. Can you send me a diff?
I mean commit r5923 which is already part of the iup subversion repo, but has not end up in a release yet: Thanks, $ svn log -c5923 ------------------------------------------------------------------------ r5923 | scuri | 2021-01-06 21:37:25 +0100 (Wed, 06 Jan 2021) | 1 line Using the main thread for the IupLua callbacks $ svn diff -c5923 Index: trunk/iup/srclua5/iuplua.c =================================================================== --- trunk/iup/srclua5/iuplua.c (revision 5922) +++ trunk/iup/srclua5/iuplua.c (revision 5923) @@ -644,9 +644,32 @@ /*************************************/ /* used by callbacks */ +#if LUA_VERSION_NUM == 501 +static void luaL_checkversion(lua_State *L) +{ + if (lua_pushthread(L) == 0) + luaL_error(L, "Must call iup.Open in main thread"); + + lua_setfield(L, LUA_REGISTRYINDEX, "MAINTHREAD"); +} +#endif + +static lua_State* get_main_thread(lua_State* L) +{ + lua_State* main_L; +#if LUA_VERSION_NUM == 501 + lua_getfield(L, LUA_REGISTRYINDEX, "MAINTHREAD"); +#else + lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_MAINTHREAD); +#endif + main_L = lua_tothread(L, -1); + lua_pop(L, 1); + return main_L; +} + IUPLUA_SDK_API void iuplua_plugstate(lua_State *L, Ihandle *ih) { - IupSetAttribute(ih, "_IUPLUA_STATE_CONTEXT",(char *) L); + IupSetAttribute(ih, "_IUPLUA_STATE_CONTEXT",(char *)get_main_thread(L)); if (IupGetGlobal("IUPLUA_THREADED")) { @@ -1388,6 +1411,8 @@ { NULL, NULL }, }; + luaL_checkversion(L); + if (!il_open(L)) return 0; _______________________________________________ Iup-users mailing list Iup-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/iup-users