From 2b5075f0e2a8223cdb07f000b7e8f874416ed3a8 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Sun, 19 Sep 2021 17:55:01 +0200 Subject: Move archive extraction in content store to async job --- src/script/lua_api/l_mainmenu.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp index 4cfbaec71..2a6a9c32d 100644 --- a/src/script/lua_api/l_mainmenu.cpp +++ b/src/script/lua_api/l_mainmenu.cpp @@ -563,7 +563,10 @@ int ModApiMainMenu::l_get_cache_path(lua_State *L) /******************************************************************************/ int ModApiMainMenu::l_get_temp_path(lua_State *L) { - lua_pushstring(L, fs::TempPath().c_str()); + if (lua_isnoneornil(L, 1) || !lua_toboolean(L, 1)) + lua_pushstring(L, fs::TempPath().c_str()); + else + lua_pushstring(L, fs::CreateTempFile().c_str()); return 1; } @@ -770,8 +773,9 @@ int ModApiMainMenu::l_get_video_drivers(lua_State *L) /******************************************************************************/ int ModApiMainMenu::l_gettext(lua_State *L) { - std::string text = strgettext(std::string(luaL_checkstring(L, 1))); - lua_pushstring(L, text.c_str()); + const char *srctext = luaL_checkstring(L, 1); + const char *text = *srctext ? gettext(srctext) : ""; + lua_pushstring(L, text); return 1; } @@ -921,5 +925,5 @@ void ModApiMainMenu::InitializeAsync(lua_State *L, int top) API_FCT(download_file); API_FCT(get_min_supp_proto); API_FCT(get_max_supp_proto); - //API_FCT(gettext); (gettext lib isn't threadsafe) + API_FCT(gettext); } -- cgit v1.2.3