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

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

Re: #9624
reviewable/pr10358/r1
NiLuJe 1 year ago committed by GitHub
parent 60849aed12
commit 53e6cf563a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1 +1 @@
Subproject commit ac93e1a8d501d778058bae83f49a065b7acf0573
Subproject commit 0bb499cafa0284a267fa715fabff8b533553051f

@ -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

@ -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}().

@ -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

@ -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

@ -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

Loading…
Cancel
Save