Fix(?) #95: hump.gamestate causes random crashes

Overwriting love.errorhandler() causes trouble. This callback must
return a game loop to display the error (see http://love2d.org/wiki/love.errorhandler).
Overwriting this callback in gamestate.registerEvents() would return
GS.errorhandler(), which would return nil and thus (maybe) causing LÖVE
to crash. On the other hand, @lemilonkh reports that LÖVE may still
crash if the love.errorhandler() is returned instead of
GS.errorhandler(), so the underlying issue might be different.

In any case, don't overwrite love.errorhandler, unless you know what you
do.
This commit is contained in:
Matthias Richter 2018-06-11 18:37:51 +02:00
parent 222f99b162
commit 3ac246dd33

View File

@ -74,8 +74,13 @@ function GS.current()
return stack[#stack] return stack[#stack]
end end
-- XXX: don't overwrite love.errorhandler by default:
-- this callback is different than the other callbacks
-- (see http://love2d.org/wiki/love.errorhandler)
-- overwriting thi callback can result in random crashes (issue #95)
local all_callbacks = { 'draw', 'update' }
-- fetch event callbacks from love.handlers -- fetch event callbacks from love.handlers
local all_callbacks = { 'draw', 'errorhandler', 'update' }
for k in pairs(love.handlers) do for k in pairs(love.handlers) do
all_callbacks[#all_callbacks+1] = k all_callbacks[#all_callbacks+1] = k
end end