From 9eb5ae6e946651bdbe532b66700bb1ed6944584f Mon Sep 17 00:00:00 2001 From: jacqueline Date: Wed, 22 Nov 2023 15:46:46 +1100 Subject: Use protected mode for lua callbacks wherever possible --- src/ui/ui_fsm.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/ui/ui_fsm.cpp') diff --git a/src/ui/ui_fsm.cpp b/src/ui/ui_fsm.cpp index ed0624df..5b4ea2a7 100644 --- a/src/ui/ui_fsm.cpp +++ b/src/ui/ui_fsm.cpp @@ -238,8 +238,7 @@ auto Lua::PushLuaScreen(lua_State* s) -> int { // Call the constructor for this screen. lua_settop(s, 1); // Make sure the function is actually at top of stack - // FIXME: This should ideally be lua_pcall, for safety. - lua_call(s, 0, 1); + lua::CallProtected(s, 0, 1); // Store the reference for the table the constructor returned. new_screen->SetObjRef(s); @@ -262,6 +261,10 @@ void Lua::exit() { lv_group_set_default(NULL); } +void Lua::react(const OnLuaError& err) { + ESP_LOGE("lua", "%s", err.message.c_str()); +} + void Lua::react(const internal::IndexSelected& ev) { auto db = sServices->database().lock(); if (!db) { -- cgit v1.2.3