diff options
author | Tim Culverhouse <tim@timculverhouse.com> | 2022-09-19 19:20:32 -0500 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-09-20 21:07:42 +0200 |
commit | a91009edf73e37b3c4f9ae37e810fcb7b466e277 (patch) | |
tree | 4ede5bd51f5b5ee7cc673877d36e2706ff57301c /lib/ui | |
parent | a31606db0d4b4e44cf3ff7f6efc9165ccf27a23e (diff) | |
download | aerc-a91009edf73e37b3c4f9ae37e810fcb7b466e277.tar.gz |
grid: protect calls to cell.Content
Many panics occur from calling Draw on a nil widget, stemming from the
grid ui element. Protect the calls to Draw from within grid to prevent
this method of panic.
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'lib/ui')
-rw-r--r-- | lib/ui/grid.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/ui/grid.go b/lib/ui/grid.go index 04a6dc42..fe1d03e8 100644 --- a/lib/ui/grid.go +++ b/lib/ui/grid.go @@ -134,7 +134,9 @@ func (grid *Grid) Draw(ctx *Context) { continue } subctx := ctx.Subcontext(x, y, width, height) - cell.Content.Draw(subctx) + if cell.Content != nil { + cell.Content.Draw(subctx) + } } } @@ -230,7 +232,9 @@ func (grid *Grid) Invalidate() { grid.invalidateLayout() grid.mutex.RLock() for _, cell := range grid.cells { - cell.Content.Invalidate() + if cell.Content != nil { + cell.Content.Invalidate() + } } grid.mutex.RUnlock() } |