Symptom: a test (test_click_to_create_drawing) started randomly failing
after I inserted a return
2 commits ago.
Cause: my tests call edit.draw, but button handlers only get cleared in
app.draw. So my tests weren't clearing button handlers, and every call
to edit.draw was accumulating states. Still unclear why those were going
to different state objects after the return
, but anyway. I'm not going
to understand every last thing that happens when things go wrong, just
guarantee they can't go wrong. And the way to do that is to decentralize
button handlers to each state that receives them.
The State object in buttons.lua doesn't have to be Editor_state. It just has to be some table that provides a Schelling Point for shared state.
PP2IIHL6EK4HBFFSYAQNV35BKIK6D4EL2JQOY7NZVJX2DXCLSMGAC
6D5MOJS4KEFIOKCBR37NXQHAJSHFIWUALGQ6DTSKWZOPS4TBIQJAC
BJ46QVIPVZL24S7MWZZIUIGDQZWZ5YEOVT2ER22HK2QPLIRPWJAAC
AVTNUQYRBW7IX2YQ3KDLVQ23RGW3BAKTAE7P73ASBYNKOHMQMH5AC
UH4YWHW5NDKNR7RS664UG4PRJNZIPNWAD5JWBEUB22JHOY2SWZKAC
OTIBCAUJ3KDQJLVDN3A536DLZGNRYMGJLORZVR3WLCGXGO6UGO6AC
LNUHQOGHIOFGJXNGA3DZLYEASLYYDGLN2I3EDZY5ANASQAHCG3YQC
4KC7I3E2DIKLIP7LQRKB5WFA2Z5XZXAU46RFHNFQU5BVEJPDX6UQC
2L5MEZV344TOZLVY3432RHJFIRVXFD6O3GWLL5O4CV66BGAFTURQC
WJBZZQE4A4KLYGS2KA254I6VN2DVXDY4XKCNAE76GTMLLQGYCUOQC
OAHNWDYG3V6EJQXJ333FD7M44E3VBZUWSKZ45SSFXVK5Q2HJUI4AC
XX7G2FFJ4QCGQGD4REAW5QFHVYAKCFUPGZCK7L6DFGS5ISVBYBQQC
ZNLTRNNKAKSMWOVZKYKFPSIOSRFS73YTFADWE4N5V3BT4UX57Q4AC
function propagate_to_button_handlers(x, y, mouse_button)
for _,ev in ipairs(Button_handlers) do
function propagate_to_button_handlers(State, x, y, mouse_button)
if State.button_handlers == nil then
return
end
for _,ev in ipairs(State.button_handlers) do