summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick White <git@njw.name>2022-01-31 17:09:52 +0000
committerNick White <git@njw.name>2022-01-31 17:09:52 +0000
commitd0305a56ac19161dad96ca1d97c4a085cf8ea191 (patch)
treec62427d73fa07b327884f5dd16b89c3aa6143745
parent4fae7d93e0c07d5f6fc4c33db389c60d95276d01 (diff)
Ensure cancel is sent to any errant processes in case of an error, and stick with "Start OCR" for go button
-rw-r--r--cmd/rescribe/gui.go12
1 files 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()