mirror of
https://github.com/koreader/koreader.git
synced 2025-12-13 20:36:53 +01:00
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:
2
base
2
base
Submodule base updated: ac93e1a8d5...0bb499cafa
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user