Skip to content

Commit

Permalink
Don't try to create text output if other renderers failed (fix regres…
Browse files Browse the repository at this point in the history
…sion)

Commit 49d7df6 added error handling,
but since that commit Tesseract used the text fallback if the user
selected output failed.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Dec 27, 2018
1 parent cc997b5 commit 993e56f
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions src/api/tesseractmain.cpp
Expand Up @@ -402,6 +402,7 @@ static void PreloadRenderers(
renderers->push_back(new tesseract::TessOsdRenderer(outputbase));
#endif // ndef DISABLED_LEGACY_ENGINE
} else {
bool error = false;
bool b;
api->GetBoolVariable("tessedit_create_hocr", &b);
if (b) {
Expand All @@ -415,20 +416,22 @@ static void PreloadRenderers(
delete renderer;
tprintf("Error, could not create hOCR output file: %s\n",
strerror(errno));
error = true;
}
}

api->GetBoolVariable("tessedit_create_alto", &b);
if (b) {
tesseract::TessAltoRenderer* renderer =
new tesseract::TessAltoRenderer(outputbase);
if (renderer->happy()) {
renderers->push_back(renderer);
} else {
delete renderer;
tprintf("Error, could not create ALTO output file: %s\n",
strerror(errno));
}
tesseract::TessAltoRenderer* renderer =
new tesseract::TessAltoRenderer(outputbase);
if (renderer->happy()) {
renderers->push_back(renderer);
} else {
delete renderer;
tprintf("Error, could not create ALTO output file: %s\n",
strerror(errno));
error = true;
}
}

api->GetBoolVariable("tessedit_create_tsv", &b);
Expand All @@ -443,6 +446,7 @@ static void PreloadRenderers(
delete renderer;
tprintf("Error, could not create TSV output file: %s\n",
strerror(errno));
error = true;
}
}

Expand All @@ -463,6 +467,7 @@ static void PreloadRenderers(
delete renderer;
tprintf("Error, could not create PDF output file: %s\n",
strerror(errno));
error = true;
}
}

Expand All @@ -477,6 +482,7 @@ static void PreloadRenderers(
delete renderer;
tprintf("Error, could not create UNLV output file: %s\n",
strerror(errno));
error = true;
}
}

Expand All @@ -490,11 +496,12 @@ static void PreloadRenderers(
delete renderer;
tprintf("Error, could not create BOX output file: %s\n",
strerror(errno));
error = true;
}
}

api->GetBoolVariable("tessedit_create_txt", &b);
if (b || renderers->empty()) {
if (b || !error && renderers->empty()) {

This comment has been minimized.

Copy link
@zdenop

zdenop Dec 29, 2018

Contributor

clang make warning for this line:

..\src\api\tesseractmain.cpp(512,21):  warning: '&&' within '||' [-Wlogical-op-parentheses]
    if (b || !error && renderers->empty()) {
          ~~ ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
..\src\api\tesseractmain.cpp(512,21):  note: place parentheses around the '&&' expression to silence this warning
    if (b || !error && renderers->empty()) {
                    ^
             (                           )

This comment has been minimized.

Copy link
@stweil

stweil Dec 29, 2018

Author Contributor

Thanks. Fixed with commit cb04913.

tesseract::TessTextRenderer* renderer =
new tesseract::TessTextRenderer(outputbase);
if (renderer->happy()) {
Expand Down

0 comments on commit 993e56f

Please sign in to comment.