From 37916a87204560f3bccbf9495b01c5d9295f1f11 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Tue, 19 Apr 2022 16:40:11 +0300 Subject: 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 not pre-initialisation is done. Sadly, this fix makes state handling in init.c even more complex with one more static Boolean flag. Change-Id: I2a8fa96740eb79725aa162cf7adc86d49a8ba603 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133175 Tested-by: Jenkins CollaboraOffice Reviewed-by: Tor Lillqvist --- desktop/source/lib/init.cxx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 392441079820..58236658c08a 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -198,6 +198,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; @@ -6537,8 +6538,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; @@ -6828,10 +6832,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); @@ -6855,6 +6865,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; -- cgit v1.2.3