aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/compose.go
diff options
context:
space:
mode:
authorTim Culverhouse <tim@timculverhouse.com>2022-10-11 18:37:38 -0500
committerRobin Jarry <robin@jarry.cc>2022-10-12 22:16:48 +0200
commit9cf69747ebc9b7d1504e07cec02866e748d57377 (patch)
tree4dbb4c60ea379ea1ab91645df4f8d813163ea5f7 /widgets/compose.go
parent87d856c10cd500fb588d2af4cb2f590e21c6cee4 (diff)
downloadaerc-9cf69747ebc9b7d1504e07cec02866e748d57377.tar.gz
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 <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'widgets/compose.go')
-rw-r--r--widgets/compose.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/widgets/compose.go b/widgets/compose.go
index 06452230..ae3bca13 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 {