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>
This commit is contained in:
parent
87d856c10c
commit
9cf69747eb
1 changed files with 3 additions and 1 deletions
|
@ -609,14 +609,16 @@ func (c *Composer) Event(event tcell.Event) bool {
|
||||||
|
|
||||||
func (c *Composer) MouseEvent(localX int, localY int, event tcell.Event) {
|
func (c *Composer) MouseEvent(localX int, localY int, event tcell.Event) {
|
||||||
c.Lock()
|
c.Lock()
|
||||||
defer c.Unlock()
|
|
||||||
for _, e := range c.focusable {
|
for _, e := range c.focusable {
|
||||||
he, ok := e.(*headerEditor)
|
he, ok := e.(*headerEditor)
|
||||||
if ok && he.focused {
|
if ok && he.focused {
|
||||||
he.focused = false
|
he.focused = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
c.Unlock()
|
||||||
c.grid.MouseEvent(localX, localY, event)
|
c.grid.MouseEvent(localX, localY, event)
|
||||||
|
c.Lock()
|
||||||
|
defer c.Unlock()
|
||||||
for i, e := range c.focusable {
|
for i, e := range c.focusable {
|
||||||
he, ok := e.(*headerEditor)
|
he, ok := e.(*headerEditor)
|
||||||
if ok && he.focused {
|
if ok && he.focused {
|
||||||
|
|
Loading…
Reference in a new issue