From 62b35cca4845edb1fa5b011032190c2fa49c3538 Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 15 Jul 2020 07:38:58 +0200 Subject: [PATCH] Prevent crash --- .../java/eu/faircode/email/ImageHelper.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/ImageHelper.java b/app/src/main/java/eu/faircode/email/ImageHelper.java index a4a348d3ea..9b8e11f3d4 100644 --- a/app/src/main/java/eu/faircode/email/ImageHelper.java +++ b/app/src/main/java/eu/faircode/email/ImageHelper.java @@ -202,7 +202,23 @@ class ImageHelper { else canvas.drawRoundRect(new RectF(dest), radius, radius, paint); // rounded paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); - canvas.drawBitmap(bitmap, source, dest, paint); + + try { + canvas.drawBitmap(bitmap, source, dest, paint); + } catch (RuntimeException ex) { + Log.e(ex); + /* + java.lang.RuntimeException: Canvas: trying to use a recycled bitmap android.graphics.Bitmap@d25d3f9 + java.lang.RuntimeException: Canvas: trying to use a recycled bitmap android.graphics.Bitmap@d25d3f9 + at android.graphics.BaseCanvas.throwIfCannotDraw(BaseCanvas.java:66) + at android.graphics.BaseCanvas.drawBitmap(BaseCanvas.java:131) + at android.graphics.Canvas.drawBitmap(Canvas.java:1608) + at eu.faircode.email.ImageHelper.makeCircular(SourceFile:205) + at eu.faircode.email.ContactInfo._get(SourceFile:403) + at eu.faircode.email.ContactInfo.get(SourceFile:177) + at eu.faircode.email.ContactInfo.get(SourceFile:164) + */ + } bitmap.recycle(); return round;