1
0
Fork 0
mirror of https://git.sr.ht/~rjarry/aerc synced 2025-10-14 21:35:15 +02:00
aerc/lib/ui
Simon Martin a57e783008 grid: fix crash upon mouse event on not yet drawn grid
If you start aerc with mouse mode activated and you happen to touch the
mouse, you might encounter this crash [1].

The problem is that if the grid has not been drawn yet, reflow has not
been called, hence {row,column}Layout is nil, and we crash accessing
their elements.

There might be ways to better synchronize things (?), but the easiest is
to simply ignore mouse events if {row,column}Layout is nil; this is what
this patch does.

[1] panic: runtime error: slice bounds out of range [:2] with capacity 0
goroutine 1 [running]:
git.sr.ht/~rjarry/aerc/lib/log.PanicHandler()
        git.sr.ht/~rjarry/aerc/lib/log/panic-logger.go:51 +0x6cf
panic({0xc8c660?, 0xc001914000?})
        runtime/panic.go:792 +0x132
git.sr.ht/~rjarry/aerc/lib/ui.(*Grid).MouseEvent(0xc000162090, 0x63, 0x16, {0xc9ac60?, 0xc000414440?})
        git.sr.ht/~rjarry/aerc/lib/ui/grid.go:144 +0x5a6
git.sr.ht/~rjarry/aerc/app.(*AccountView).MouseEvent(0x142db50?, 0xcd1640?, 0xc0000478f0?, {0xc9ac60?, 0xc000414440?})
        git.sr.ht/~rjarry/aerc/app/account.go:192 +0x25
[...]

Signed-off-by: Simon Martin <simon@nasilyan.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2025-09-26 16:54:32 +02:00
..
borders.go aerc: change event interfaces to vaxis events 2024-02-12 13:48:42 +01:00
box.go aerc: change event interfaces to vaxis events 2024-02-12 13:48:42 +01:00
context.go treewide: replace interface{} with any 2025-04-07 10:51:05 +02:00
fill.go fill: replace tcell.Style with vaxis.Style 2024-02-12 13:48:47 +01:00
grid.go grid: fix crash upon mouse event on not yet drawn grid 2025-09-26 16:54:32 +02:00
interfaces.go account: allow indicating new messages in the tab title 2025-04-07 10:51:14 +02:00
popover.go aerc: change event interfaces to vaxis events 2024-02-12 13:48:42 +01:00
stack.go mouse: use vaxis mouse events 2024-02-12 13:48:56 +01:00
string.go account: allow indicating new messages in the tab title 2025-04-07 10:51:14 +02:00
tab.go reload: fix crash when reloading via IPC 2025-09-23 14:02:37 +02:00
table.go treewide: replace interface{} with any 2025-04-07 10:51:05 +02:00
text.go style: use vaxis style everywhere 2024-02-12 13:48:50 +01:00
textinput.go ui: implement C-left/C-right cursor controls for textinput 2025-06-30 11:05:30 +02:00
textinput_test.go ui: implement C-left/C-right cursor controls for textinput 2025-06-30 11:05:30 +02:00
ui.go reload: fix crash when reloading via IPC 2025-09-23 14:02:37 +02:00