From 47143318ba9e827d2ba1d277627d53a6e1e612de Mon Sep 17 00:00:00 2001 From: rustdesk Date: Wed, 12 Jun 2024 01:40:54 +0800 Subject: [PATCH] ensure nextRgba called no matter if image created --- flutter/lib/utils/image.dart | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/flutter/lib/utils/image.dart b/flutter/lib/utils/image.dart index e62239501..6280555ba 100644 --- a/flutter/lib/utils/image.dart +++ b/flutter/lib/utils/image.dart @@ -13,13 +13,14 @@ Future decodeImageFromPixels( int? rowBytes, int? targetWidth, int? targetHeight, - VoidCallback? onPixelsCopied, + VoidCallback? onPixelsCopied, // must ensure onPixelsCopied is called no matter this function succeeds bool allowUpscaling = true, }) async { if (targetWidth != null) { assert(allowUpscaling || targetWidth <= width); if (!(allowUpscaling || targetWidth <= width)) { print("not allow upscaling but targetWidth > width"); + onPixelsCopied?.call(); return null; } } @@ -27,6 +28,7 @@ Future decodeImageFromPixels( assert(allowUpscaling || targetHeight <= height); if (!(allowUpscaling || targetHeight <= height)) { print("not allow upscaling but targetHeight > height"); + onPixelsCopied?.call(); return null; } } @@ -36,6 +38,7 @@ Future decodeImageFromPixels( buffer = await ui.ImmutableBuffer.fromUint8List(pixels); onPixelsCopied?.call(); } catch (e) { + onPixelsCopied?.call(); return null; }