summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-10-07 21:45:57 +1100
committerJesse Duffield <jessedduffield@gmail.com>2020-10-10 00:23:01 +1100
commit795e4da8b8fa08eb2e55cd7587ddba077402e9ad (patch)
tree05d71ef0b00522fad3ac4878bf13a2914f22599d
parent79e59d5460d838203bc79ac86c0ba529305ba2a9 (diff)
do not put mutexes on state else we might unlock an unlocked mutex
-rw-r--r--pkg/gui/commits_panel.go8
-rw-r--r--pkg/gui/files_panel.go8
-rw-r--r--pkg/gui/global_handlers.go4
-rw-r--r--pkg/gui/gui.go3
-rw-r--r--pkg/gui/line_by_line_panel.go8
-rw-r--r--pkg/gui/remotes_panel.go4
-rw-r--r--pkg/gui/status_panel.go4
7 files changed, 20 insertions, 19 deletions
diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go
index b5803a6a0..10932c1c8 100644
--- a/pkg/gui/commits_panel.go
+++ b/pkg/gui/commits_panel.go
@@ -110,8 +110,8 @@ func (gui *Gui) refreshCommits() error {
}
func (gui *Gui) refreshCommitsWithLimit() error {
- gui.State.Mutexes.BranchCommitsMutex.Lock()
- defer gui.State.Mutexes.BranchCommitsMutex.Unlock()
+ gui.Mutexes.BranchCommitsMutex.Lock()
+ defer gui.Mutexes.BranchCommitsMutex.Unlock()
builder := commands.NewCommitListBuilder(gui.Log, gui.GitCommand, gui.OSCommand, gui.Tr)
@@ -132,8 +132,8 @@ func (gui *Gui) refreshCommitsWithLimit() error {
}
func (gui *Gui) refreshRebaseCommits() error {
- gui.State.Mutexes.BranchCommitsMutex.Lock()
- defer gui.State.Mutexes.BranchCommitsMutex.Unlock()
+ gui.Mutexes.BranchCommitsMutex.Lock()
+ defer gui.Mutexes.BranchCommitsMutex.Unlock()
builder := commands.NewCommitListBuilder(gui.Log, gui.GitCommand, gui.OSCommand, gui.Tr)
diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go
index 67d1a6eee..0f498a9ac 100644
--- a/pkg/gui/files_panel.go
+++ b/pkg/gui/files_panel.go
@@ -81,11 +81,11 @@ func (gui *Gui) selectFile(alreadySelected bool) error {
}
func (gui *Gui) refreshFilesAndSubmodules() error {
- gui.State.Mutexes.RefreshingFilesMutex.Lock()
+ gui.Mutexes.RefreshingFilesMutex.Lock()
gui.State.IsRefreshingFiles = true
defer func() {
gui.State.IsRefreshingFiles = false
- gui.State.Mutexes.RefreshingFilesMutex.Unlock()
+ gui.Mutexes.RefreshingFilesMutex.Unlock()
}()
selectedFile := gui.getSelectedFile()
@@ -517,8 +517,8 @@ func (gui *Gui) pullFiles(opts PullFilesOptions) error {
}
func (gui *Gui) pullWithMode(mode string, opts PullFilesOptions) error {
- gui.State.Mutexes.FetchMutex.Lock()
- defer gui.State.Mutexes.FetchMutex.Unlock()
+ gui.Mutexes.FetchMutex.Lock()
+ defer gui.Mutexes.FetchMutex.Unlock()
err := gui.GitCommand.Fetch(
commands.FetchOptions{
diff --git a/pkg/gui/global_handlers.go b/pkg/gui/global_handlers.go
index 6c344cdbd..d87f7a77b 100644
--- a/pkg/gui/global_handlers.go
+++ b/pkg/gui/global_handlers.go
@@ -164,8 +164,8 @@ func (gui *Gui) handleInfoClick(g *gocui.Gui, v *gocui.View) error {
}
func (gui *Gui) fetch(canPromptForCredentials bool) (err error) {
- gui.State.Mutexes.FetchMutex.Lock()
- defer gui.State.Mutexes.FetchMutex.Unlock()
+ gui.Mutexes.FetchMutex.Lock()
+ defer gui.Mutexes.FetchMutex.Unlock()
fetchOpts := commands.FetchOptions{}
if canPromptForCredentials {
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go
index 9ce5df7c2..e9c321949 100644
--- a/pkg/gui/gui.go
+++ b/pkg/gui/gui.go
@@ -113,6 +113,8 @@ type Gui struct {
// or the events we've recorded in a prior session
RecordedEvents []RecordedEvent
StartTime time.Time
+
+ Mutexes guiStateMutexes
}
type RecordedEvent struct {
@@ -318,7 +320,6 @@ type guiState struct {
SplitMainPanel bool
RetainOriginalDir bool
IsRefreshingFiles bool
- Mutexes guiStateMutexes
Searching searchingState
ScreenMode int
SideView *gocui.View
diff --git a/pkg/gui/line_by_line_panel.go b/pkg/gui/line_by_line_panel.go
index cb93468a3..96c29bc6d 100644
--- a/pkg/gui/line_by_line_panel.go
+++ b/pkg/gui/line_by_line_panel.go
@@ -25,8 +25,8 @@ const (
// returns whether the patch is empty so caller can escape if necessary
// both diffs should be non-coloured because we'll parse them and colour them here
func (gui *Gui) refreshLineByLinePanel(diff string, secondaryDiff string, secondaryFocused bool, selectedLineIdx int) (bool, error) {
- gui.State.Mutexes.LineByLinePanelMutex.Lock()
- defer gui.State.Mutexes.LineByLinePanelMutex.Unlock()
+ gui.Mutexes.LineByLinePanelMutex.Lock()
+ defer gui.Mutexes.LineByLinePanelMutex.Unlock()
state := gui.State.Panels.LineByLine
@@ -418,8 +418,8 @@ func (gui *Gui) lineByLineNavigateTo(selectedLineIdx int) error {
}
func (gui *Gui) withLBLActiveCheck(f func(*lineByLinePanelState) error) error {
- gui.State.Mutexes.LineByLinePanelMutex.Lock()
- defer gui.State.Mutexes.LineByLinePanelMutex.Unlock()
+ gui.Mutexes.LineByLinePanelMutex.Lock()
+ defer gui.Mutexes.LineByLinePanelMutex.Unlock()
state := gui.State.Panels.LineByLine
if state == nil {
diff --git a/pkg/gui/remotes_panel.go b/pkg/gui/remotes_panel.go
index 7e321d81f..9d1450003 100644
--- a/pkg/gui/remotes_panel.go
+++ b/pkg/gui/remotes_panel.go
@@ -158,8 +158,8 @@ func (gui *Gui) handleFetchRemote(g *gocui.Gui, v *gocui.View) error {
}
return gui.WithWaitingStatus(gui.Tr.FetchingRemoteStatus, func() error {
- gui.State.Mutexes.FetchMutex.Lock()
- defer gui.State.Mutexes.FetchMutex.Unlock()
+ gui.Mutexes.FetchMutex.Lock()
+ defer gui.Mutexes.FetchMutex.Unlock()
// TODO: test this
err := gui.GitCommand.FetchRemote(remote.Name, gui.promptUserForCredential)
diff --git a/pkg/gui/status_panel.go b/pkg/gui/status_panel.go
index 3abf0829d..4a50aed98 100644
--- a/pkg/gui/status_panel.go
+++ b/pkg/gui/status_panel.go
@@ -12,8 +12,8 @@ import (
// never call this on its own, it should only be called from within refreshCommits()
func (gui *Gui) refreshStatus() {
- gui.State.Mutexes.RefreshingStatusMutex.Lock()
- defer gui.State.Mutexes.RefreshingStatusMutex.Unlock()
+ gui.Mutexes.RefreshingStatusMutex.Lock()
+ defer gui.Mutexes.RefreshingStatusMutex.Unlock()
currentBranch := gui.currentBranch()
if currentBranch == nil {