Aliciana / subtitleedit

Automatically exported from code.google.com/p/subtitleedit
0 stars 0 forks source link

Bckground thread for ocr vobsub never stops #143

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
when debugging last sources downloaded I noticed that cancelling ocr run (when 
importing vobsubs) doesn't stop the tesseract thread 

What steps will reproduce the problem?
1. import vobsub
2. use ocr by tesseract
3. start ocr
4. cancel ocr

What is the expected output? What do you see instead?
in the tempdir/ the png files (given to tesseract exe) are still created and 
deleted although we have stopped the job

What version of the product are you using? On what operating system?
SE334 on windows 7 x64

Patchs to apply on SE334-CSharp-SourceCode\Forms\VobSubOcr.cs :

 private void ButtonStopClick(object sender, EventArgs e)
        {
            _abort = true;
            _tesseractThread.CancelAsync();
            buttonStop.Enabled = false;
            Application.DoEvents();
            progressBar1.Visible = false;
            labelStatus.Text = string.Empty;
        }

 void TesseractThreadDoWork(object sender, DoWorkEventArgs e)
        {
            var bitmap = (Bitmap)e.Argument;
            if (_tesseractAsyncIndex >= 0 && _tesseractAsyncIndex < _tesseractAsyncStrings.Length)
            {
                if (string.IsNullOrEmpty(_tesseractAsyncStrings[_tesseractAsyncIndex]) && bitmap != null)
                    _tesseractAsyncStrings[_tesseractAsyncIndex] = Tesseract3DoOcrViaExe(bitmap, _languageId, "-psm 6"); // 6 = Assume a single uniform block of text.);

                if (((BackgroundWorker)sender).CancellationPending)
                {
                    e.Cancel = true;
                }
            }
        }

Original issue reported on code.google.com by Me.anouar@gmail.com on 7 May 2013 at 9:38

GoogleCodeExporter commented 9 years ago
SE has moved to GitHub - please re-add this issue at GitHub if it's still 
important :)
https://github.com/SubtitleEdit/subtitleedit/issues

Original comment by nikse.dk@gmail.com on 4 Feb 2014 at 5:24