aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorTim Culverhouse <tim@timculverhouse.com>2022-09-15 13:16:31 -0500
committerRobin Jarry <robin@jarry.cc>2022-09-15 20:50:38 +0200
commitc7df28d6325bcb67e9d075192d9fa357417984e7 (patch)
tree7bafcecadb7093b0360d944c045939875684838a /widgets
parentcf319129de36a2832674466e28bfa2dbb9bfc0cc (diff)
downloadaerc-c7df28d6325bcb67e9d075192d9fa357417984e7.tar.gz
terminal: check for context before calling it's methods
The terminal widget internally uses several context methods. Check that context is not nil before calling any method to prevent panics. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'widgets')
-rw-r--r--widgets/terminal.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/widgets/terminal.go b/widgets/terminal.go
index 3a496dea..c8b97d3a 100644
--- a/widgets/terminal.go
+++ b/widgets/terminal.go
@@ -65,7 +65,9 @@ func (term *Terminal) Close(err error) {
if !term.closed && term.OnClose != nil {
term.OnClose(err)
}
- term.ctx.HideCursor()
+ if term.ctx != nil {
+ term.ctx.HideCursor()
+ }
term.closed = true
}
@@ -126,7 +128,7 @@ func (term *Terminal) Draw(ctx *ui.Context) {
func (term *Terminal) draw() {
term.vterm.Draw()
- if term.focus && !term.closed {
+ if term.focus && !term.closed && term.ctx != nil {
if !term.cursorShown {
term.ctx.HideCursor()
} else {
@@ -182,7 +184,9 @@ func (term *Terminal) HandleEvent(ev tcell.Event) bool {
term.draw()
// Perform a tcell screen.Show() to show our updates
// immediately
- term.ctx.Show()
+ if term.ctx != nil {
+ term.ctx.Show()
+ }
term.invalidate()
return true
case *tcellterm.EventTitle: