~rjarry/aerc

a91009edf73e37b3c4f9ae37e810fcb7b466e277 — Tim Culverhouse 6 days ago a31606d
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>
1 files changed, 6 insertions(+), 2 deletions(-)

M lib/ui/grid.go
M lib/ui/grid.go => lib/ui/grid.go +6 -2
@@ 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()
}