From 18b3e4939931c0d2bf779d2e52cb0c90e282ec97 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sun, 23 Mar 2025 16:59:16 +0530 Subject: Fix segfault with evaluate, add keymap accidentally popping wrong value + add demnu config.lua example --- src/LuaRuntime.hpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/LuaRuntime.hpp') diff --git a/src/LuaRuntime.hpp b/src/LuaRuntime.hpp index 9f672e9..3d44282 100644 --- a/src/LuaRuntime.hpp +++ b/src/LuaRuntime.hpp @@ -7,6 +7,11 @@ #include "AsyncEventLoop.hpp" #include "widgets/WebViewStack.hpp" +#define preserveTop(STATE, BODY) \ + int __top = lua_gettop(STATE); \ + BODY; \ + lua_settop(STATE, __top); + class LuaRuntime : public QObject { Q_OBJECT @@ -17,16 +22,14 @@ public: } void evaluate(QString code); - QVariant evaluateSync(QString code); - void loadFile(QString path); + QVariant evaluateSync(QString code); void stopEventLoop(); void startEventLoop(); - - QVariant getValue(int idx); - DELEGATE(eventLoop, queueTask, queueTask) + + QVariant getLuaValue(int idx); DEFINE_GETTER(getState, state) signals: @@ -39,6 +42,7 @@ signals: protected: LuaRuntime(); ~LuaRuntime(); + void initWebLib(); static int lua_onUrlOpen(lua_State *state); static int lua_onUrlTabOpen(lua_State *state); static int lua_addKeymap(lua_State *state); -- cgit v1.3.1