Make c2_later throw not longjmp

This commit is contained in:
Mm2PL 2024-10-10 13:38:03 +02:00
parent 340f50c4ab
commit 53ae8ab8ca
No known key found for this signature in database
GPG key ID: 94AC9B80EFA15ED9
4 changed files with 6 additions and 13 deletions

View file

@ -23,6 +23,7 @@
# include <sol/variadic_args.hpp>
# include <sol/variadic_results.hpp>
# include <stdexcept>
# include <string>
# include <utility>
@ -104,12 +105,12 @@ void c2_log(sol::this_state L, Plugin *pl, LogLevel lvl,
}
}
int c2_later(sol::this_state L, sol::protected_function callback, int time)
void c2_later(sol::this_state L, sol::protected_function callback, int time)
{
auto *pl = getApp()->getPlugins()->getPluginByStatePtr(L);
if (pl == nullptr)
{
return luaL_error(L, "c2.later: internal error: no plugin?");
throw std::runtime_error("c2.later: internal error: no plugin?");
}
sol::state_view lua(L);
@ -137,8 +138,6 @@ int c2_later(sol::this_state L, sol::protected_function callback, int time)
main.registry()[name.toStdString()] = sol::nil;
});
timer->start();
return 0;
}
sol::variadic_results g_load(sol::this_state s, sol::object data)

View file

@ -123,7 +123,7 @@ void c2_log(sol::this_state L, Plugin *pl, LogLevel lvl,
* @lua@param msec number How long to wait.
* @exposed c2.later
*/
int c2_later(sol::this_state L, sol::protected_function callback, int time);
void c2_later(sol::this_state L, sol::protected_function callback, int time);
// These ones are global
sol::variadic_results g_load(sol::this_state s, sol::object data);

View file

@ -3,6 +3,7 @@
# include "common/network/NetworkResult.hpp"
# include <lua.h>
# include <sol/sol.hpp>
# include <memory>

View file

@ -8,14 +8,7 @@
# include <lauxlib.h>
# include <lua.h>
# include <QString>
# include <sol/forward.hpp>
# include <sol/in_place.hpp>
# include <sol/object.hpp>
# include <sol/protected_function_result.hpp>
# include <sol/state_view.hpp>
# include <sol/types.hpp>
# include <sol/variadic_args.hpp>
# include <sol/variadic_results.hpp>
# include <sol/sol.hpp>
# include <cerrno>
# include <stdexcept>