desktop/source/lib/init.cxx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
New commits: commit 92db31fa44040706d627fb5cafe6b0e2641b0bec Author: Tor Lillqvist <[email protected]> AuthorDate: Tue Apr 19 16:40:11 2022 +0300 Commit: Tor Lillqvist <[email protected]> CommitDate: Thu Apr 21 21:19:41 2022 +0200 Fix regression in the iOS app (and possibly the Android and GTK apps) The problem was caused by my remote font downloading changes. We need to be more careful in lo_initialize() and libreofficekit_hook_2() to distinguish whether the code is called from "normal" Online (with "pre-initialisation" through lok_preinit_2()) or otherwise, for instance the iOS app (where pre-initialisation is not done). Sadly, this fix makes state handling in init.cxx even more complex with one more static Boolean flag. Change-Id: I2a8fa96740eb79725aa162cf7adc86d49a8ba603 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133181 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Tor Lillqvist <[email protected]> diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 6ab245c55d35..df5f67ad3c2b 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -200,6 +200,7 @@ using namespace desktop; using namespace utl; static LibLibreOffice_Impl *gImpl = nullptr; +static bool lok_preinit_2_called = false; static std::weak_ptr< LibreOfficeKitClass > gOfficeClass; static std::weak_ptr< LibreOfficeKitDocumentClass > gDocumentClass; @@ -6500,8 +6501,11 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char if (pThis == nullptr) { eStage = PRE_INIT; - SAL_INFO("lok", "Create libreoffice object"); - gImpl = new LibLibreOffice_Impl(); + if (lok_preinit_2_called) + { + SAL_INFO("lok", "Create libreoffice object"); + gImpl = new LibLibreOffice_Impl(); + } } else if (bPreInited) eStage = SECOND_INIT; @@ -6788,10 +6792,16 @@ LibreOfficeKit *libreofficekit_hook_2(const char* install_path, const char* user { static bool alreadyCalled = false; - if (!alreadyCalled) + if ((!lok_preinit_2_called && !gImpl) || (lok_preinit_2_called && !alreadyCalled)) { alreadyCalled = true; + if (!lok_preinit_2_called) + { + SAL_INFO("lok", "Create libreoffice object"); + gImpl = new LibLibreOffice_Impl(); + } + if (!lo_initialize(gImpl, install_path, user_profile_url)) { lo_destroy(gImpl); @@ -6815,6 +6825,7 @@ int lok_preinit(const char* install_path, const char* user_profile_url) SAL_JNI_EXPORT int lok_preinit_2(const char* install_path, const char* user_profile_url, LibLibreOffice_Impl** kit) { + lok_preinit_2_called = true; int result = lo_initialize(nullptr, install_path, user_profile_url); if (kit != nullptr) *kit = gImpl;
