mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2025-01-01 14:17:29 +01:00
Fix crash when tasks are scheduled for the next timestep into priority 2 from inside a function dispatched from priority 2
This commit is contained in:
parent
528531e37b
commit
06b8fa561e
@ -132,6 +132,7 @@ local function globalstep(dtime)
|
||||
-- Run tasks that must be run this timestep (now-main)
|
||||
every_globalstep(dtime)
|
||||
local next_main_task = run_queue[2]
|
||||
run_queue[2] = nil
|
||||
while next_main_task do
|
||||
local task = next_main_task
|
||||
next_main_task = task.next
|
||||
@ -139,7 +140,6 @@ local function globalstep(dtime)
|
||||
task:func(dtime)
|
||||
free_task(task)
|
||||
end
|
||||
run_queue[2] = nil
|
||||
|
||||
-- Launch asynchronous tasks that may be issued any time (background-async)
|
||||
local next_background_async_task = run_queue[3]
|
||||
|
@ -190,5 +190,16 @@ describe('vl_scheduler',function()
|
||||
call_globalstep(0.05)
|
||||
end
|
||||
end)
|
||||
it('can schedule new tasks recursively and they run on the next timestep',function()
|
||||
local vl_scheduler = _G.vl_scheduler
|
||||
vl_scheduler.after(0, 2, function() end)
|
||||
vl_scheduler.after(0, 2, function()
|
||||
vl_scheduler.after(0, 2, function() end)
|
||||
vl_scheduler.after(0, 2, function() end)
|
||||
end)
|
||||
assert.no_error(function()
|
||||
call_globalstep(0.05)
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user