Deal with table.pack corner-cases properly (#10350)

c.f., https://github.com/koreader/koreader-base/pull/1603 for more
details.

Re: #9624
This commit is contained in:
NiLuJe
2023-04-24 00:21:05 +02:00
committed by GitHub
parent 60849aed12
commit 53e6cf563a
6 changed files with 8 additions and 8 deletions

2
base

Submodule base updated: ac93e1a8d5...0bb499cafa

View File

@@ -41,7 +41,7 @@ for _, widget in ipairs(self) do
end
end
-- If not consumed by children, consume it ourself
return self["on"..event.name](self, unpack(event.args))
return self["on"..event.name](self, unpack(event.args, 1, event.args.n))
```
## Event system

View File

@@ -49,7 +49,7 @@ function Dbg:turnOn()
if post_guard then
post_guard(...)
end
return unpack(values)
return unpack(values, 1, values.n)
end
end
--- Use this instead of a regular Lua @{assert}().

View File

@@ -674,7 +674,7 @@ function Trapper:dismissableRunInSubprocess(task, trap_widget_or_string, task_re
if task_returns_simple_string then
return completed, ret_values
else
return completed, unpack(ret_values)
return completed, unpack(ret_values, 1, ret_values.n)
end
end
return completed

View File

@@ -361,7 +361,7 @@ function UIManager:debounce(seconds, immediate, action)
else
is_scheduled = false
if not immediate then
result = action(unpack(args))
result = action(unpack(args, 1, args.n))
end
if not is_scheduled then
-- This check is needed because action can recursively call debounced_action_wrapper
@@ -376,7 +376,7 @@ function UIManager:debounce(seconds, immediate, action)
self:scheduleIn(seconds, scheduled_action)
is_scheduled = true
if immediate then
result = action(unpack(args))
result = action(unpack(args, 1, args.n))
end
end
return result
@@ -987,7 +987,7 @@ function UIManager:_checkTasks()
-- NOTE: Said task's action might modify _task_queue.
-- To avoid race conditions and catch new upcoming tasks during this call,
-- we repeatedly check the head of the queue (c.f., #1758).
task.action(unpack(task.args))
task.action(unpack(task.args, 1, task.args.n))
else
-- As the queue is sorted in descending order, it's safe to assume all items are currently future tasks.
wait_until = task_time

View File

@@ -34,7 +34,7 @@ By default, it's `"on"..Event.name`.
function EventListener:handleEvent(event)
if self[event.handler] then
--print("EventListener:handleEvent:", event.handler, "handled by", debug.getinfo(self[event.handler], "S").short_src, self)
return self[event.handler](self, unpack(event.args))
return self[event.handler](self, unpack(event.args, 1, event.args.n))
end
end