mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-29 16:21:29 +00:00
PDFViewer: Fix indexing error in ErrorsView
I confused myself when implementing this, plus I tested using pages that had errors in pages 1 and 2, so the index and the number of the page (internally represented as 0-indexed) was always the same. When opening files with errors on higher pages it became evident that there was an issue with how I was reading the errors per page from the corresponding ModelIndex object.
This commit is contained in:
parent
7e9019a9c3
commit
b8dc05a08e
Notes:
sideshowbarker
2024-07-17 02:58:20 +09:00
Author: https://github.com/rtobar Commit: https://github.com/SerenityOS/serenity/commit/b8dc05a08e Pull-request: https://github.com/SerenityOS/serenity/pull/16597
|
@ -49,8 +49,7 @@ public:
|
|||
return static_cast<int>(m_paged_errors.size());
|
||||
}
|
||||
if (!index.parent().is_valid()) {
|
||||
auto errors_in_page = m_paged_errors.get(index.row()).release_value().size();
|
||||
return static_cast<int>(errors_in_page);
|
||||
return static_cast<int>(error_count_in_page(index));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -103,7 +102,7 @@ public:
|
|||
case Columns::Page:
|
||||
return m_pages_with_errors[index.row()] + 1;
|
||||
case Columns::Message:
|
||||
return DeprecatedString::formatted("{} errors", m_paged_errors.get(index.row()).release_value().size());
|
||||
return DeprecatedString::formatted("{} errors", error_count_in_page(index));
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
@ -149,6 +148,13 @@ private:
|
|||
return count;
|
||||
}
|
||||
|
||||
size_t error_count_in_page(GUI::ModelIndex const& index) const
|
||||
{
|
||||
VERIFY(!index.parent().is_valid());
|
||||
auto page = m_pages_with_errors[index.row()];
|
||||
return m_paged_errors.get(page).release_value().size();
|
||||
}
|
||||
|
||||
Vector<u32> m_pages_with_errors;
|
||||
PagedErrors m_paged_errors;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue