diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2020-10-08 08:01:04 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2020-10-10 00:23:01 +1100 |
commit | 4c9ec88be57ed75c198d19020374bae0365b6e00 (patch) | |
tree | 8b69a8fd7ab64009aa028c61bd9a8a109a721efd /pkg/gui/patch_building_panel.go | |
parent | 9011271a014025c514adf72b1d1ee69fbc7f3373 (diff) |
fix mutex deadlock
Diffstat (limited to 'pkg/gui/patch_building_panel.go')
-rw-r--r-- | pkg/gui/patch_building_panel.go | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/pkg/gui/patch_building_panel.go b/pkg/gui/patch_building_panel.go index 3f6a71c95..6ae41de6e 100644 --- a/pkg/gui/patch_building_panel.go +++ b/pkg/gui/patch_building_panel.go @@ -17,7 +17,7 @@ func (gui *Gui) getFromAndReverseArgsForDiff(to string) (string, bool) { return from, reverse } -func (gui *Gui) refreshPatchBuildingPanel(selectedLineIdx int) error { +func (gui *Gui) refreshPatchBuildingPanel(selectedLineIdx int, state *lBlPanelState) error { if !gui.GitCommand.PatchManager.Active() { return gui.handleEscapePatchBuildingPanel() } @@ -45,7 +45,7 @@ func (gui *Gui) refreshPatchBuildingPanel(selectedLineIdx int) error { return err } - empty, err := gui.refreshLineByLinePanel(diff, secondaryDiff, false, selectedLineIdx) + empty, err := gui.refreshLineByLinePanel(diff, secondaryDiff, false, selectedLineIdx, state) if err != nil { return err } @@ -57,8 +57,15 @@ func (gui *Gui) refreshPatchBuildingPanel(selectedLineIdx int) error { return nil } +func (gui *Gui) handleRefreshPatchBuildingPanel(selectedLineIdx int) error { + gui.Mutexes.LineByLinePanelMutex.Lock() + defer gui.Mutexes.LineByLinePanelMutex.Unlock() + + return gui.refreshPatchBuildingPanel(selectedLineIdx, gui.State.Panels.LineByLine) +} + func (gui *Gui) handleToggleSelectionForPatch() error { - return gui.withLBLActiveCheck(func(state *lineByLinePanelState) error { + err := gui.withLBLActiveCheck(func(state *lBlPanelState) error { toggleFunc := gui.GitCommand.PatchManager.AddFileLineRange filename := gui.getSelectedCommitFileName() includedLineIndices, err := gui.GitCommand.PatchManager.GetFileIncLineIndices(filename) @@ -81,16 +88,18 @@ func (gui *Gui) handleToggleSelectionForPatch() error { gui.Log.Error(err) } - if err := gui.refreshCommitFilesView(); err != nil { - return err - } - - if err := gui.refreshPatchBuildingPanel(-1); err != nil { - return err - } - return nil }) + + if err != nil { + return err + } + + if err := gui.refreshCommitFilesView(); err != nil { + return err + } + + return nil } func (gui *Gui) handleEscapePatchBuildingPanel() error { |