summaryrefslogtreecommitdiffstats
path: root/pkg/gui/arrangement.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2021-04-06 16:01:07 +1000
committerJesse Duffield <jessedduffield@gmail.com>2021-04-06 19:34:32 +1000
commit8c93289a728991c51e787bcf7dc72813ce0e1a0e (patch)
tree637cea41eb0cc6dc34330cacfbbaae2f8ea3f7c0 /pkg/gui/arrangement.go
parentb1df0fafa216bb2784bedb82bdbeace9df931a02 (diff)
reduce chance of deadlock by using a RW mutex on the context stack
Diffstat (limited to 'pkg/gui/arrangement.go')
-rw-r--r--pkg/gui/arrangement.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/pkg/gui/arrangement.go b/pkg/gui/arrangement.go
index 422941243..125e089d2 100644
--- a/pkg/gui/arrangement.go
+++ b/pkg/gui/arrangement.go
@@ -181,8 +181,8 @@ func (gui *Gui) getWindowDimensions(informationStr string, appStatus string) map
// the default behaviour when accordian mode is NOT in effect. If it is in effect
// then when it's accessed it will have weight 2, not 1.
func (gui *Gui) getDefaultStashWindowBox() *boxlayout.Box {
- gui.State.ContextManager.Lock()
- defer gui.State.ContextManager.Unlock()
+ gui.State.ContextManager.RLock()
+ defer gui.State.ContextManager.RUnlock()
box := &boxlayout.Box{Window: "stash"}
stashWindowAccessed := false
@@ -281,8 +281,8 @@ func (gui *Gui) sidePanelChildren(width int, height int) []*boxlayout.Box {
func (gui *Gui) currentSideWindowName() string {
// there is always one and only one cyclable context in the context stack. We'll look from top to bottom
- gui.State.ContextManager.Lock()
- defer gui.State.ContextManager.Unlock()
+ gui.State.ContextManager.RLock()
+ defer gui.State.ContextManager.RUnlock()
for idx := range gui.State.ContextManager.ContextStack {
reversedIdx := len(gui.State.ContextManager.ContextStack) - 1 - idx