mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 15:12:45 +00:00 
			
		
		
		
	PDFViewer: Avoid errors due to copying of ErrorOr
The handle_error took PDFErrorOr<T> objects by value, meaning that their inner values (the error or value stored in the underlying Variant) were somehow copied over. In the first instance where this lambda is called with T = NonnullRefPtr, resulting in funky behavior (invalid NonnullRefPtr state with a VALIDATE fail): if there is no error then the PDFErrorOr<T> copy is destroyed, which might be causing the underlying NonnullRefPtr to be destroyed, but somehow the original in the caller context gets affected and fails verification. The solution seems simple anyway: just pass the value by reference (lvalue or rvalue) so the original object can be used directly, avoiding destruction.
This commit is contained in:
		
							parent
							
								
									124ab5bec6
								
							
						
					
					
						commit
						d4ecdf3ced
					
				
					 1 changed files with 1 additions and 1 deletions
				
			
		|  | @ -338,7 +338,7 @@ void PDFViewerWidget::open_file(Core::File& file) | |||
| { | ||||
|     window()->set_title(DeprecatedString::formatted("{} - PDF Viewer", file.filename())); | ||||
| 
 | ||||
|     auto handle_error = [&]<typename T>(PDF::PDFErrorOr<T> maybe_error) { | ||||
|     auto handle_error = [&](auto&& maybe_error) { | ||||
|         if (maybe_error.is_error()) { | ||||
|             auto error = maybe_error.release_error(); | ||||
|             warnln("{}", error.message()); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Rodrigo Tobar
						Rodrigo Tobar