[Libreoffice-commits] core.git: android/source
Michael Weghorn (via logerrit)
logerrit at kemper.freedesktop.org
Wed Apr 1 07:59:09 UTC 2020
android/source/src/java/org/libreoffice/LOKitThread.java | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
New commits:
commit 55661298bb3e9087a89a08637e4285f090c4e0e8
Author: Michael Weghorn <m.weghorn at posteo.de>
AuthorDate: Wed Apr 1 09:00:13 2020 +0200
Commit: Michael Weghorn <m.weghorn at posteo.de>
CommitDate: Wed Apr 1 09:58:34 2020 +0200
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 at posteo.de>
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;
More information about the Libreoffice-commits
mailing list