@@ -443,28 +443,30 @@ impl Widget for ImageViewer {
443443 if let Event :: Signal = event {
444444 let mut to_remove = false ;
445445 if let Some ( ( _background_task_id, receiver) ) = & mut self . receiver {
446- while let Ok ( image_buffer_res) = receiver. try_recv ( ) {
447- match image_buffer_res {
448- Ok ( image_buffer) => {
449- let rotated_image = self . view . rotated_image ( ids ! ( rotated_image) ) ;
450- let texture = image_buffer. into_new_texture ( cx) ;
451- rotated_image. set_texture ( cx, Some ( texture) ) ;
452- to_remove = true ;
453- cx. action ( ImageViewerAction :: Show ( LoadState :: FinishedBackgroundDecoding ) ) ;
454-
455- }
456- Err ( error) => {
457- let error = match error {
458- ImageError :: JpgDecode ( _) | ImageError :: PngDecode ( _) => ImageViewerError :: UnsupportedFormat ,
459- ImageError :: EmptyData => ImageViewerError :: BadData ,
460- ImageError :: PathNotFound ( _) => ImageViewerError :: NotFound ,
461- ImageError :: UnsupportedFormat => ImageViewerError :: UnsupportedFormat ,
462- _ => ImageViewerError :: BadData ,
463- } ;
464- cx. action ( ImageViewerAction :: Show ( LoadState :: Error ( error) ) ) ;
446+ match receiver. try_recv ( ) {
447+ Ok ( image_buffer_res) => {
448+ match image_buffer_res {
449+ Ok ( image_buffer) => {
450+ let rotated_image = self . view . rotated_image ( ids ! ( rotated_image) ) ;
451+ let texture = image_buffer. into_new_texture ( cx) ;
452+ rotated_image. set_texture ( cx, Some ( texture) ) ;
453+ to_remove = true ;
454+ cx. action ( ImageViewerAction :: Show ( LoadState :: FinishedBackgroundDecoding ) ) ;
455+
456+ }
457+ Err ( error) => {
458+ let error = match error {
459+ ImageError :: JpgDecode ( _) | ImageError :: PngDecode ( _) => ImageViewerError :: UnsupportedFormat ,
460+ ImageError :: EmptyData => ImageViewerError :: BadData ,
461+ ImageError :: PathNotFound ( _) => ImageViewerError :: NotFound ,
462+ ImageError :: UnsupportedFormat => ImageViewerError :: UnsupportedFormat ,
463+ _ => ImageViewerError :: BadData ,
464+ } ;
465+ cx. action ( ImageViewerAction :: Show ( LoadState :: Error ( error) ) ) ;
466+ }
465467 }
466468 }
467- break
469+ Err ( _ ) => { }
468470 }
469471 }
470472 if to_remove {
@@ -729,7 +731,7 @@ impl ImageViewerRef {
729731pub enum LoadState {
730732 /// The image is currently being loaded with its loading image texture and its image size.
731733 /// This texture is usually the image texture that's being selected.
732- Loading ( Arc < Option < Texture > > , DVec2 ) ,
734+ Loading ( std :: rc :: Rc < Option < Texture > > , DVec2 ) ,
733735 /// The image has been successfully loaded given the data.
734736 Loaded ( Arc < [ u8 ] > ) ,
735737 /// The image has been loaded from background thread.
0 commit comments