Disallow requiring love.graphics and love.window in threads.

This commit is contained in:
Sasha Szpakowski
2026-06-18 20:49:08 -03:00
parent 4b43c74a29
commit a3dae27a72
3 changed files with 19 additions and 0 deletions
+7
View File
@@ -1064,6 +1064,13 @@ lua_State *luax_getpinnedthread(lua_State *L)
return thread;
}
extern "C" int luax_module_threaderror(lua_State *L)
{
// Module name is the first param in the stack.
const char *name = luaL_checkstring(L, 1);
return luaL_error(L, "The %s module cannot be used in thread code.", name);
}
void luax_markdeprecated(lua_State *L, int level, const char *name, APIType api)
{
luax_markdeprecated(L, level, name, api, DEPRECATED_NO_REPLACEMENT, nullptr);
+8
View File
@@ -493,6 +493,14 @@ lua_State *luax_insistpinnedthread(lua_State *L);
**/
lua_State *luax_getpinnedthread(lua_State *L);
/**
* Lua C function to use with luax_preload when the given module should not
* be allowed on a thread. Must be called from the thread's code.
**/
extern "C" {
int luax_module_threaderror(lua_State *L);
}
/**
* Mark a function as deprecated. Should only be called inside wrapper function
* code.
+4
View File
@@ -68,6 +68,10 @@ void LuaThread::threadFunction()
lua_pop(L, 1);
#endif // LOVE_BUILD_STANDALONE
// We might want to add more input-related modules to this list.
luax_preload(L, luax_module_threaderror, "love.window");
luax_preload(L, luax_module_threaderror, "love.graphics");
luax_require(L, "love.thread");
lua_pop(L, 1);