[Libreoffice-commits] online.git: android/app common/Unit.cpp

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Feb 13 15:39:08 UTC 2019


 android/app/src/main/cpp/androidapp.cpp |    2 ++
 common/Unit.cpp                         |    7 +++++++
 2 files changed, 9 insertions(+)

New commits:
commit 7f0f6e5a36e28981a4954e60c2c1911b12d932d7
Author:     Jan Holesovsky <kendy at collabora.com>
AuthorDate: Wed Feb 13 16:37:54 2019 +0100
Commit:     Jan Holesovsky <kendy at collabora.com>
CommitDate: Wed Feb 13 16:37:54 2019 +0100

    android: Restart if anything goes wrong.
    
    But sleep for a bit of time between the runs to avoid a busy loop.
    
    Change-Id: I90a7bee052d82e8a0488e6a34fb1b6f43e6f6e64

diff --git a/android/app/src/main/cpp/androidapp.cpp b/android/app/src/main/cpp/androidapp.cpp
index 25dfc63c7..45aefd63d 100644
--- a/android/app/src/main/cpp/androidapp.cpp
+++ b/android/app/src/main/cpp/androidapp.cpp
@@ -11,6 +11,7 @@
 #include <jni.h>
 #include <android/log.h>
 
+#include <chrono>
 #include <thread>
 
 #include <FakeSocket.hpp>
@@ -265,6 +266,7 @@ Java_org_libreoffice_androidapp_MainActivity_createLOOLWSD(JNIEnv*, jobject)
                         loolwsd->run(1, argv);
                         delete loolwsd;
                         LOG_TRC("One run of LOOLWSD completed");
+                        std::this_thread::sleep_for(std::chrono::milliseconds(100));
                     }
                 }).detach();
 
diff --git a/common/Unit.cpp b/common/Unit.cpp
index 820f465ff..ae1c363a6 100644
--- a/common/Unit.cpp
+++ b/common/Unit.cpp
@@ -68,7 +68,14 @@ UnitBase *UnitBase::linkAndCreateUnit(UnitType type, const std::string &unitLibP
 
 bool UnitBase::init(UnitType type, const std::string &unitLibPath)
 {
+#if !MOBILEAPP
     assert(!Global);
+#else
+    // The LOOLWSD initialization is called in a loop on mobile, allow reuse
+    if (Global)
+        return true;
+#endif
+
     if (!unitLibPath.empty())
     {
         Global = linkAndCreateUnit(type, unitLibPath);


More information about the Libreoffice-commits mailing list