Skip to content

Commit f857bfe

Browse files
committed
Guard against ObjectDisposedException in Post call
1 parent 7a7a94f commit f857bfe

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

Source/ZXing.Net.Mobile.Android/ZXingTextureView.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,13 @@ void SetSurfaceTransform(SurfaceTexture st, int width, int height)
296296
var transform = new Matrix();
297297
transform.SetScale(1f, aspectRatio * width / height); // lock on to width
298298

299-
Post(() => SetTransform(transform)); // ensure we use the right thread when updating transform
299+
Post(() => {
300+
try
301+
{
302+
SetTransform(transform);
303+
}
304+
catch (ObjectDisposedException) { } // todo: What to do here?! For now we squash :-/
305+
}); // ensure we use the right thread when updating transform
300306

301307
Log.Debug(MobileBarcodeScanner.TAG, $"Aspect ratio: {aspectRatio}, Transform: {transform}");
302308

0 commit comments

Comments
 (0)