From d366e1e987e62ab6b3e1d71efb7f860d9ef09757 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Thu, 5 Oct 2023 16:15:47 +0200 Subject: [PATCH] Fix loading of sublangs (regression) Model files which where defined with tessedit_load_sublangs in another model file where no longer loaded since Tesseract release 5.0.0-rc2. Fixes: 9091055783ac8f03 ("Fix loading of additional model files") Signed-off-by: Stefan Weil --- src/ccmain/tessedit.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ccmain/tessedit.cpp b/src/ccmain/tessedit.cpp index c97ce83c2d..03997beeab 100644 --- a/src/ccmain/tessedit.cpp +++ b/src/ccmain/tessedit.cpp @@ -306,9 +306,10 @@ int Tesseract::init_tesseract(const std::string &arg0, const std::string &textba // Add any languages that this language requires bool loaded_primary = false; // Load the rest into sub_langs_. - // A range based for loop does not work here because langs_to_load + // WARNING: A range based for loop does not work here because langs_to_load // might be changed in the loop when a new submodel is found. - for (auto &lang_to_load : langs_to_load) { + for (size_t lang_index = 0; lang_index < langs_to_load.size(); ++lang_index) { + auto &lang_to_load = langs_to_load[lang_index]; if (!IsStrInList(lang_to_load, langs_not_to_load)) { const char *lang_str = lang_to_load.c_str(); Tesseract *tess_to_init;