From 9cf69747ebc9b7d1504e07cec02866e748d57377 Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Tue, 11 Oct 2022 18:37:38 -0500 Subject: [PATCH] compose: don't lock call to composer.grid.MouseEvent The MouseEvent method of the composer passes on the mouse event to it's underlying grid while the composer is locked. The underlying grid then passes on the mouse event to child objects of the grid, which are referenced via fields of the composer (c.editor is a field in composer but a child of c.grid, for example). When the grid attempts to pass on the mouse event, it is referencing a pointer which is locked, and a deadlock occurs due to the original lock in composer.MouseEvent. Unlock before calling the grid.MouseEvent, and lock the composer again after it is called. Signed-off-by: Tim Culverhouse Acked-by: Robin Jarry --- widgets/compose.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/widgets/compose.go b/widgets/compose.go index 0645223..ae3bca1 100644 --- a/widgets/compose.go +++ b/widgets/compose.go @@ -609,14 +609,16 @@ func (c *Composer) Event(event tcell.Event) bool { func (c *Composer) MouseEvent(localX int, localY int, event tcell.Event) { c.Lock() - defer c.Unlock() for _, e := range c.focusable { he, ok := e.(*headerEditor) if ok && he.focused { he.focused = false } } + c.Unlock() c.grid.MouseEvent(localX, localY, event) + c.Lock() + defer c.Unlock() for i, e := range c.focusable { he, ok := e.(*headerEditor) if ok && he.focused {