mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 17:52:45 +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
					
				
					 1 changed files with 9 additions and 3 deletions
				
			
		|  | @ -49,8 +49,7 @@ public: | ||||||
|             return static_cast<int>(m_paged_errors.size()); |             return static_cast<int>(m_paged_errors.size()); | ||||||
|         } |         } | ||||||
|         if (!index.parent().is_valid()) { |         if (!index.parent().is_valid()) { | ||||||
|             auto errors_in_page = m_paged_errors.get(index.row()).release_value().size(); |             return static_cast<int>(error_count_in_page(index)); | ||||||
|             return static_cast<int>(errors_in_page); |  | ||||||
|         } |         } | ||||||
|         return 0; |         return 0; | ||||||
|     } |     } | ||||||
|  | @ -103,7 +102,7 @@ public: | ||||||
|             case Columns::Page: |             case Columns::Page: | ||||||
|                 return m_pages_with_errors[index.row()] + 1; |                 return m_pages_with_errors[index.row()] + 1; | ||||||
|             case Columns::Message: |             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: |             default: | ||||||
|                 VERIFY_NOT_REACHED(); |                 VERIFY_NOT_REACHED(); | ||||||
|             } |             } | ||||||
|  | @ -149,6 +148,13 @@ private: | ||||||
|         return count; |         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; |     Vector<u32> m_pages_with_errors; | ||||||
|     PagedErrors m_paged_errors; |     PagedErrors m_paged_errors; | ||||||
| }; | }; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Rodrigo Tobar
						Rodrigo Tobar