summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2020-04-01 09:00:13 +0200
committerMichael Weghorn <m.weghorn@posteo.de>2020-04-01 09:58:34 +0200
commit55661298bb3e9087a89a08637e4285f090c4e0e8 (patch)
tree533525c0af7629f13a9bd9f587963bfcce215140 /android
parenteed94d15a49ad2038a59a3a1bfaa4a66a27ed540 (diff)
tdf#131195 android: Don't destroy doc while loading it
Since the 'refresh()' in 'LOKitThread::loadDocument' is not executed synchronously but posted to the main handler, this needs to be synchronized to prevent the document from being deleted while it's being used. The problem when pressing the "back" button while loading the document was that LOKitThread::closeDocument would cause the document to be deleted while it was still being used, causing a crash on C++ side when using the dangling pointer to the document in function 'doc_getDocumentType' (desktop/source/lib/init.cxx). Change-Id: I37da4c4cf8d787327d72c2f449d9cef5d79223c3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91460 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'android')
-rw-r--r--android/source/src/java/org/libreoffice/LOKitThread.java8
1 files changed, 6 insertions, 2 deletions
diff --git a/android/source/src/java/org/libreoffice/LOKitThread.java b/android/source/src/java/org/libreoffice/LOKitThread.java
index 9c216b54fb1f..e554f0800cf0 100644
--- a/android/source/src/java/org/libreoffice/LOKitThread.java
+++ b/android/source/src/java/org/libreoffice/LOKitThread.java
@@ -236,7 +236,10 @@ class LOKitThread extends Thread {
LOKitShell.getMainHandler().post(new Runnable() {
@Override
public void run() {
- refresh();
+ // synchronize to avoid deletion while loading
+ synchronized (LOKitThread.this) {
+ refresh();
+ }
}
});
LOKitShell.hideProgressSpinner(mContext);
@@ -290,7 +293,8 @@ class LOKitThread extends Thread {
/**
* Close the currently loaded document.
*/
- private void closeDocument() {
+ // needs to be synchronized to not destroy doc while it's loaded
+ private synchronized void closeDocument() {
if (mTileProvider != null) {
mTileProvider.close();
mTileProvider = null;