on error, switch to a whole other event loop

akkartik
Dec 12, 2024, 5:40 AM
5UNXE4KMGRIKURKCT7O7JZ7QXUWB2MMTJRZJCJ2CVPEDHC237UBAC

Dependencies

  • [2] NVEA3SMU reorg
  • [3] EZZWF7WP define App.run_frame at the top level
  • [4] TBWAE64A app is now live, can communicate with driver
  • [5] 5WHW3IDO fix initialization errors using driver.love
  • [6] DMS3N5YD undo an ancient hack; be an idiomatic LÖVE app
  • [7] 3QNOKBFM beginnings of a test harness
  • [8] AVTNUQYR basic test-enabled framework
  • [9] DJSIRUMD a more radical attempt at ignoring nil y's
  • [10] AGJXIDOF hardcode some assumptions about how this app uses love
  • [11] 36Z442IV back to commit 8123959e52f without code editing
  • [*] LRDM35CE app running again
  • [*] T7QIIGQ6 attempt at better error recovery

Change contents

  • edit in live.lua at line 382
    [2.1310]
    [13.9011]
    local main_run_frame = App.run_frame
    -- one iteration of the event loop when showing an error
    -- return nil to continue the event loop, non-nil to quit
    local error_frame_keys_down = {}
    function error_run_frame()
    if love.event then
    love.event.pump()
    for name, a,b,c,d,e,f in love.event.poll() do
    if name == 'quit' then
    return a or 0
    elseif name == 'keypressed' then
    error_frame_keys_down[a] = true
    -- C-c
    if a == 'c' and (error_frame_keys_down.lctrl or error_frame_keys_down.rctrl) then
    love.system.setClipboardText(Error_message)
    end
    elseif name == 'keyreleased' then
    error_frame_keys_down[a] = nil
    App.run_frame = main_run_frame
    end
    end
    end
  • edit in live.lua at line 407
    [13.9012]
    [13.9163]
    local dt = love.timer.step()
    Current_time = Current_time + dt
    live.update(dt)
    love.graphics.origin()
    love.graphics.clear(love.graphics.getBackgroundColor())
    love.graphics.setColor(0,0,1)
    love.graphics.rectangle('fill', 0,0, App.screen.width, App.screen.height)
    love.graphics.setColor(1,1,1)
    love.graphics.printf(Error_message, 40,40, 600)
    love.graphics.present()
    love.timer.sleep(0.001)
    -- returning nil continues the loop
    end
  • edit in live.lua at line 441
    [14.2212]
    [13.10774]
    App.run_frame = error_run_frame
  • edit in app.lua at line 158
    [4.123][4.171:186](),[4.171][4.171:186]()
    local dt = 0
  • replacement in app.lua at line 170
    [3.276][3.276:303]()
    App.run_frame = function()
    [3.276]
    [3.303]
    function App.run_frame()
  • replacement in app.lua at line 183
    [4.551][3.546:571]()
    dt = love.timer.step()
    [4.551]
    [3.571]
    local dt = love.timer.step()