Fork of lines.love without drawings; useful starting point for further forks

bugfix: crash when naming points in a drawing

This only happens when pressing C-n inside a drawing in normal (not maximized) mode.

The reason is complicated. First, the baseline:

  • When pressing C-o: run.keychord: starty is not nil run.keychord: current drawing is nil Drawing.keychord C-o: doesn't set current drawing plan_draw (only happens in normal mode): clears starty in all lines Drawing.update: all good ✓

  • When pressing C-n: run.keychord: starty is not nil run.keychord: current drawing is nil Drawing.keychord C-n: sets current drawing <=== plan_draw: clears starty in all lines Drawing.update: BOOM

Ugh.

When is starty set? Drawing.draw. This is why I can clean it up with abandon. But: frame = events -> update -> draw

  • plan_draw clears starty while processing events
  • Drawing.update blows up in here <===
  • Drawing.draw is about to set starty

So one possible interpretation here is that this is an unfortunate interaction of two special-cases:

  • draw should never mutate state, but it's just the most convenient place to track starty
  • keystrokes never set current drawing – except rare operations like naming and moving points

So the current prescription: any code called from within update needs to protect against starty being nil.

Ugh X-(

Created by  Kartik K. Agaram  on September 15, 2023
SEBFLWZVK6Y7GX62DXQFWJG4IFV2VTXHGEWS25ZIQYKC3AQW5TFQC
Change contents