fix input timer queue

if new timer has a timeout later than a timer in queue, the
new timer will be discarded and never be pushed into timer queue.
This is fixed by pushing new timer without timeout checking
and then sorting the queue according to timer timeouts.

This should fix #520 and #495.
pull/525/head
chrox 10 years ago
parent 54c59437f9
commit 21b0b24b14

@ -433,15 +433,10 @@ function Input:setTimeout(cb, tv_out)
callback = cb,
deadline = tv_out,
}
for k,v in ipairs(self.timer_callbacks) do
if v.deadline > tv_out then
table.insert(self.timer_callbacks, k, item)
break
end
end
if #self.timer_callbacks <= 0 then
self.timer_callbacks[1] = item
end
table.insert(self.timer_callbacks, item)
table.sort(self.timer_callbacks, function(v1,v2)
return v1.deadline < v2.deadline
end)
end
function Input:handleKeyBoardEv(ev)

Loading…
Cancel
Save