From d0305a56ac19161dad96ca1d97c4a085cf8ea191 Mon Sep 17 00:00:00 2001 From: Nick White Date: Mon, 31 Jan 2022 17:09:52 +0000 Subject: Ensure cancel is sent to any errant processes in case of an error, and stick with "Start OCR" for go button --- cmd/rescribe/gui.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/rescribe/gui.go b/cmd/rescribe/gui.go index f4ac9bd..d5a132f 100644 --- a/cmd/rescribe/gui.go +++ b/cmd/rescribe/gui.go @@ -281,7 +281,6 @@ func startGui(log log.Logger, cmd string, training string, tessdir string) error fmt.Printf("\nAbort\n") cancel() progressBar.SetValue(0.0) - gobtn.SetText("Process OCR") for _, v := range []fyne.Disableable{folderBtn, pdfBtn, gbookBtn, trainingOpts, gobtn} { v.Enable() } @@ -361,7 +360,6 @@ func startGui(log log.Logger, cmd string, training string, tessdir string) error fmt.Fprintf(os.Stderr, msg) progressBar.SetValue(0.0) - gobtn.SetText("Process OCR") for _, v := range []fyne.Disableable{folderBtn, pdfBtn, gbookBtn, trainingOpts, gobtn} { v.Enable() } @@ -388,8 +386,9 @@ func startGui(log log.Logger, cmd string, training string, tessdir string) error fmt.Fprintf(os.Stderr, msg) } + cancel() + ctx, cancel = context.WithCancel(context.Background()) progressBar.SetValue(0.0) - gobtn.SetText("Process OCR") for _, v := range []fyne.Disableable{folderBtn, pdfBtn, gbookBtn, trainingOpts, gobtn} { v.Enable() } @@ -404,8 +403,9 @@ func startGui(log log.Logger, cmd string, training string, tessdir string) error dialog.ShowError(errors.New(msg), myWindow) fmt.Fprintf(os.Stderr, msg) + cancel() + ctx, cancel = context.WithCancel(context.Background()) progressBar.SetValue(0.0) - gobtn.SetText("Process OCR") for _, v := range []fyne.Disableable{folderBtn, pdfBtn, gbookBtn, trainingOpts, gobtn} { v.Enable() } @@ -430,12 +430,13 @@ func startGui(log log.Logger, cmd string, training string, tessdir string) error return } if err != nil { + cancel() + ctx, cancel = context.WithCancel(context.Background()) msg := fmt.Sprintf("Error during processing: %v\n", err) dialog.ShowError(errors.New(msg), myWindow) fmt.Fprintf(os.Stderr, msg) progressBar.SetValue(0.0) - gobtn.SetText("Process OCR") for _, v := range []fyne.Disableable{folderBtn, pdfBtn, gbookBtn, trainingOpts, gobtn} { v.Enable() } @@ -444,7 +445,6 @@ func startGui(log log.Logger, cmd string, training string, tessdir string) error } progressBar.SetValue(1.0) - gobtn.SetText("Process OCR") for _, v := range []fyne.Disableable{folderBtn, pdfBtn, gbookBtn, trainingOpts, gobtn} { v.Enable() -- cgit v1.2.1-24-ge1ad