diff options
author | Christian Lohmaier <lohmaier+LibreOffice@googlemail.com> | 2018-04-07 21:01:10 +0200 |
---|---|---|
committer | Christian Lohmaier <lohmaier+LibreOffice@googlemail.com> | 2018-04-07 22:17:08 +0200 |
commit | 59f88e62f53cf54f441f51456767f6ba0e52ca54 (patch) | |
tree | cc353543a71f50bddfe351de5e4900f367868b35 /android | |
parent | e3104eb246bdf623ad01fee8ba192a4926cb264c (diff) |
prevent crash on invalid bitmap size
sometimes the width and height cannot be determined properly (and 0 in
that case), and this causes IllegalArgumentException when trying to
create the Bitmap
Change-Id: Id001c40d0febf9e85b4db5c0318a77e1f880353a
Diffstat (limited to 'android')
-rw-r--r-- | android/source/src/java/org/libreoffice/LOKitTileProvider.java | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/android/source/src/java/org/libreoffice/LOKitTileProvider.java b/android/source/src/java/org/libreoffice/LOKitTileProvider.java index a96f6092363c..bf2c2601e7cd 100644 --- a/android/source/src/java/org/libreoffice/LOKitTileProvider.java +++ b/android/source/src/java/org/libreoffice/LOKitTileProvider.java @@ -467,8 +467,13 @@ class LOKitTileProvider implements TileProvider { if (mDocument != null) mDocument.paintTile(buffer, widthPixel, heightPixel, 0, 0, (int) mWidthTwip, (int) mHeightTwip); - Bitmap bitmap = Bitmap.createBitmap(widthPixel, heightPixel, Bitmap.Config.ARGB_8888); - bitmap.copyPixelsFromBuffer(buffer); + Bitmap bitmap = null; + try { + bitmap = Bitmap.createBitmap(widthPixel, heightPixel, Bitmap.Config.ARGB_8888); + bitmap.copyPixelsFromBuffer(buffer); + } catch (IllegalArgumentException e) { + Log.e(LOGTAG, "width (" + widthPixel + ") and height (" + heightPixel + ") must not be 0! (ToDo: likely timing issue)"); + } if (bitmap == null) { Log.w(LOGTAG, "Thumbnail not created!"); } |