Skip to content

Commit

Permalink
LuaFAR: a temporary workaround in processing timer events
Browse files Browse the repository at this point in the history
  • Loading branch information
shmuz committed Jan 22, 2025
1 parent 4d9cf65 commit adb7a17
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
2 changes: 1 addition & 1 deletion plugins/luamacro/_globalinfo.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function export.GetGlobalInfo()
return {
Version = { 3, 0, 0, 863 },
Version = { 3, 0, 0, 864 },
MinFarVersion = { 3, 0, 0, 6380 },
Guid = win.Uuid("4EBBEFC8-2084-4B7F-94C0-692CE136894D"),
Title = "LuaMacro",
Expand Down
5 changes: 4 additions & 1 deletion plugins/luamacro/changelog
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
shmuel 2025-01-23 00:39:05+02:00 - build 864

1. LuaFAR: a temporary workaround in processing timer events.

shmuel 2025-01-22 20:36:47+02:00 - build 863

1. LuaFAR plugins: the timer queue is closed in DllMain/DLL_PROCESS_DETACH.
Was: in ExitFARW.


shmuel 2025-01-21 21:18:49+02:00 - build 862

1. Force garbage collection on reloading macrofiles
Expand Down
33 changes: 18 additions & 15 deletions plugins/luamacro/luafar/exported.c
Original file line number Diff line number Diff line change
Expand Up @@ -1506,31 +1506,34 @@ intptr_t LF_ProcessSynchroEvent(lua_State* L, const struct ProcessSynchroEventIn
case SYNCHRO_TIMER_CALL:
if (!sd.timerData->needClose)
{
lua_rawgeti(L, LUA_REGISTRYINDEX, sd.timerData->tabRef); //+1: Table
lua_rawgeti(L, LUA_REGISTRYINDEX, sd.timerData->hndRef); //+1: weak table
lua_rawgeti(L, LUA_REGISTRYINDEX, sd.timerData->tabRef); //+2: Table

if (lua_istable(L, -1))
if (lua_istable(L, -2) && lua_istable(L, -1))
{
int size, index;
int tabPos = lua_gettop(L);
lua_getfield(L, tabPos, "n"); //+2: table size
lua_getfield(L, tabPos, "n"); //+3: table size
size = (int)lua_tointeger(L, -1);
lua_rawgeti(L, tabPos, 1); // function
lua_rawgeti(L, LUA_REGISTRYINDEX, sd.timerData->hndRef); // weak table
lua_rawgeti(L, -1, 1); // Lua timer handle
lua_remove(L, -2); // remove the weak table from the stack
lua_rawgeti(L, tabPos, 1); //+4 function
lua_rawgeti(L, tabPos-1, 1); //+5 Lua timer handle

for (index=2; index<=size; index++) // parameters
lua_rawgeti(L, tabPos, index);

if (pcall_msg(L, size, 1) == 0) //+3
if (!lua_isnil(L, -1)) // ### A DIRTY HACK (hopefully temporary)
{
if (lua_isnumber(L,-1)) ret = lua_tointeger(L,-1);
for (index=2; index<=size; index++) // parameters
lua_rawgeti(L, tabPos, index);

if (pcall_msg(L, size, 1) == 0) //+4
{
if (lua_isnumber(L,-1)) ret = lua_tointeger(L,-1);

lua_pop(L,3);
lua_pop(L,4);
}
else lua_pop(L,3);
}
else lua_pop(L,2);
else lua_pop(L, 5); //+0
}
else lua_pop(L, 1);
else lua_pop(L, 2);
}
break;

Expand Down
2 changes: 1 addition & 1 deletion plugins/luamacro/luafar/version.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#include <farversion.hpp>

#define PLUGIN_BUILD 863
#define PLUGIN_BUILD 864

0 comments on commit adb7a17

Please sign in to comment.