Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some compiler warnings #4246

Merged
merged 2 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/api/pagerenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ char *TessBaseAPI::GetPAGEText(ETEXT_DESC *monitor, int page_number) {
std::stringstream word_str;
std::stringstream page_str;

float x1, y1, x2, y2, word_conf, line_conf, block_conf;
float x1, y1, x2, y2;

tesseract::Orientation orientation_block = ORIENTATION_PAGE_UP;
tesseract::WritingDirection writing_direction_block =
Expand Down Expand Up @@ -824,6 +824,7 @@ char *TessBaseAPI::GetPAGEText(ETEXT_DESC *monitor, int page_number) {
break;
}

float block_conf = 0;
if (res_it->IsAtBeginningOf(RIL_BLOCK)) {
// Add Block to reading order
reading_order_str << "\t\t\t\t<RegionRefIndexed " << "index=\"" << rcnt
Expand Down Expand Up @@ -870,6 +871,7 @@ char *TessBaseAPI::GetPAGEText(ETEXT_DESC *monitor, int page_number) {
bool skewed_flag = (orientation_block != ORIENTATION_PAGE_UP &&
orientation_block != ORIENTATION_PAGE_DOWN);

float line_conf = 0;
if (res_it->IsAtBeginningOf(RIL_TEXTLINE)) {
// writing_direction_before = writing_direction;
line_conf = ((res_it->Confidence(RIL_TEXTLINE)) / 100.);
Expand Down Expand Up @@ -900,7 +902,7 @@ char *TessBaseAPI::GetPAGEText(ETEXT_DESC *monitor, int page_number) {
bool last_word_in_line = res_it->IsAtFinalElement(RIL_TEXTLINE, RIL_WORD);
bool last_word_in_cblock = res_it->IsAtFinalElement(RIL_BLOCK, RIL_WORD);

word_conf = ((res_it->Confidence(RIL_WORD)) / 100.);
float word_conf = ((res_it->Confidence(RIL_WORD)) / 100.);

// Create word stream if word level output is active
if (LEVELFLAG > 0) {
Expand Down
16 changes: 16 additions & 0 deletions src/training/pango/pango_font_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,20 @@ bool PangoFontInfo::CoversUTF8Text(const char *utf8_text, int byte_length) const
int len = it.get_utf8(tmp);
tmp[len] = '\0';
tlog(2, "'%s' (U+%x) not covered by font\n", tmp, *it);
#if PANGO_VERSION_CHECK(1, 52, 0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/GNOME/pango/blob/1.44/NEWS#L5

Overview of changes in .44.0

...

  • Make PangoCoverage a GObject

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking this up. So the check could be modified to check for 1.44.0. Since 1.52.0 pango_coverage_unref is marked as deprecated and causes a compiler warning.

g_object_unref(coverage);
#else
pango_coverage_unref(coverage);
#endif
g_object_unref(font);
return false;
}
}
#if PANGO_VERSION_CHECK(1, 52, 0)
g_object_unref(coverage);
#else
pango_coverage_unref(coverage);
#endif
g_object_unref(font);
return true;
}
Expand Down Expand Up @@ -303,7 +311,11 @@ int PangoFontInfo::DropUncoveredChars(std::string *utf8_text) const {
my_strnmove(out, utf8_char, utf8_len);
out += utf8_len;
}
#if PANGO_VERSION_CHECK(1, 52, 0)
g_object_unref(coverage);
#else
pango_coverage_unref(coverage);
#endif
g_object_unref(font);
utf8_text->resize(out - utf8_text->c_str());
return num_dropped_chars;
Expand Down Expand Up @@ -603,7 +615,11 @@ int FontUtils::FontScore(const std::unordered_map<char32, int64_t> &ch_map,
ch_flags->push_back(covered);
}
}
#if PANGO_VERSION_CHECK(1, 52, 0)
g_object_unref(coverage);
#else
pango_coverage_unref(coverage);
#endif
g_object_unref(font);
return ok_chars;
}
Expand Down
Loading