summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2020-03-06 08:54:12 +0100
committerMichael Weghorn <m.weghorn@posteo.de>2020-03-06 16:44:24 +0100
commitbf331e388845a5d213b40a3894db8ffc6560e1da (patch)
tree5f99919948ab5675bb1fa6d9c513935a67e0188b /android
parentd0b9d7c2915f45ad34cc8a764cb9674cfbf3203b (diff)
android: LibreOfficeMainActivity::onStop: Add null check
'mTileProvider' can be null here, e.g. while loading the document. This fixes a crash that could be reproduced e.g. by * open a document * press the "back button" while the document is still being loaded (Most easily reproducibly right after app installation, since loading the first doc takes a very long time then.) Relevant log messages from `adb logcat` output: E AndroidRuntime: java.lang.RuntimeException: Unable to stop activity {org.libreoffice/org.libreoffice.LibreOfficeMainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void org.libreoffice.LOKitTileProvider.cacheDocument()' on a null object reference E AndroidRuntime: at android.app.ActivityThread.callActivityOnStop(ActivityThread.java:4624) E AndroidRuntime: at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:4594) E AndroidRuntime: at android.app.ActivityThread.handleStopActivity(ActivityThread.java:4669) E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:233) E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201) E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173) E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97) E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016) E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:107) E AndroidRuntime: at android.os.Looper.loop(Looper.java:214) E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7356) E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930) E AndroidRuntime: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void org.libreoffice.LOKitTileProvider.cacheDocument()' on a null object reference E AndroidRuntime: at org.libreoffice.LibreOfficeMainActivity.onStop(LibreOfficeMainActivity.java:427) E AndroidRuntime: at android.app.Instrumentation.callActivityOnStop(Instrumentation.java:1466) E AndroidRuntime: at android.app.Activity.performStop(Activity.java:8018) E AndroidRuntime: at android.app.ActivityThread.callActivityOnStop(ActivityThread.java:4616) E AndroidRuntime: ... 13 more Change-Id: I9f8a9329801b721dbfbc0a49c150f88ec341059c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90088 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'android')
-rw-r--r--android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java3
1 files changed, 2 insertions, 1 deletions
diff --git a/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java b/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java
index 628305d01f13..cbc628e94e48 100644
--- a/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java
+++ b/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java
@@ -424,7 +424,8 @@ public class LibreOfficeMainActivity extends AppCompatActivity implements Settin
protected void onStop() {
Log.i(LOGTAG, "onStop..");
//save document to cache
- mTileProvider.cacheDocument();
+ if (mTileProvider != null)
+ mTileProvider.cacheDocument();
hideSoftKeyboardDirect();
LOKitShell.sendCloseEvent();
super.onStop();