summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-01-21 14:55:27 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-01-26 10:27:42 +0100
commit94ec99db8a35094758f240451a8a7acbe4bab540 (patch)
treedacef79e2640d595fc4dbd61c12d152e78530afe /android
parent2b67566adef887664ca41457e4ebeb327cb95e56 (diff)
android: fix crash in tile provider while closing the document
The problem was that for large documents if "back" was pressed quickly, then we closed the document, but rendering thumbnails for the different parts was still in progress. Just make sure we don't crash when the underlying document is gone. E/AndroidRuntime( 8902): java.lang.NullPointerException E/AndroidRuntime( 8902): at org.libreoffice.LOKitTileProvider.thumbnail(LOKitTileProvider.java:244) E/AndroidRuntime( 8902): at org.libreoffice.ThumbnailCreator$ThumbnailCreationTask.getThumbnail(ThumbnailCreator.java:78) E/AndroidRuntime( 8902): at org.libreoffice.LOKitThread.createThumbnail(LOKitThread.java:170) E/AndroidRuntime( 8902): at org.libreoffice.LOKitThread.processEvent(LOKitThread.java:148) E/AndroidRuntime( 8902): at org.libreoffice.LOKitThread.run(LOKitThread.java:120) Change-Id: I93e8e1ea19545ca196ef6f59d19528bb42f3676d
Diffstat (limited to 'android')
-rw-r--r--android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java9
1 files changed, 8 insertions, 1 deletions
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
index 0970bbbc2a0c..78a592bce704 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
@@ -241,7 +241,8 @@ public class LOKitTileProvider implements TileProvider, Document.MessageCallback
Log.w(LOGTAG, "Thumbnail size: " + getPageWidth() + " " + getPageHeight() + " " + widthPixel + " " + heightPixel);
ByteBuffer buffer = ByteBuffer.allocateDirect(widthPixel * heightPixel * 4);
- mDocument.paintTile(buffer, widthPixel, heightPixel, 0, 0, (int) mWidthTwip, (int) mHeightTwip);
+ 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);
@@ -287,12 +288,18 @@ public class LOKitTileProvider implements TileProvider, Document.MessageCallback
@Override
public void changePart(int partIndex) {
+ if (mDocument == null)
+ return;
+
mDocument.setPart(partIndex);
resetDocumentSize();
}
@Override
public int getCurrentPartNumber() {
+ if (mDocument == null)
+ return 0;
+
return mDocument.getPart();
}