aboutsummaryrefslogtreecommitdiff
path: root/src/LuaRuntime.cpp
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2025-05-02 00:48:02 +0530
committerAkshay Nair <phenax5@gmail.com>2025-05-02 16:23:56 +0530
commit8a71de53c002b7afdd516cff7190896d40496483 (patch)
tree96345b83f4ce010e84f0ba4b52f2846c449287bb /src/LuaRuntime.cpp
parent00efc9757475b3b347fee0ce2aaccfbf4b1c33b5 (diff)
downloadnull-browser-8a71de53c002b7afdd516cff7190896d40496483.tar.gz
null-browser-8a71de53c002b7afdd516cff7190896d40496483.zip
Fix luv callback error triggering exit and segfault
Diffstat (limited to '')
-rw-r--r--src/LuaRuntime.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/LuaRuntime.cpp b/src/LuaRuntime.cpp
index eaf3df7..07ddb67 100644
--- a/src/LuaRuntime.cpp
+++ b/src/LuaRuntime.cpp
@@ -1,4 +1,5 @@
#include <QtCore>
+#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <lua.hpp>
@@ -19,6 +20,10 @@ LuaRuntime::LuaRuntime() {
init_web_api();
}
+int luv_callback(lua_State *state, int nargs, int nresults, int flags) {
+ return luv_cfpcall(state, nargs, nresults, flags | LUVF_CALLBACK_NOEXIT);
+}
+
void LuaRuntime::start_event_loop() {
if (event_loop != nullptr)
stop_event_loop();
@@ -28,6 +33,7 @@ void LuaRuntime::start_event_loop() {
// Load `uv` (luv)
luv_set_loop(state, event_loop->get_uv_loop());
+ luv_set_callback(state, &luv_callback);
luaopen_luv(state);
lua_setglobal(state, uv_global_name);
}