From e4b2c44d846673d26807a8233dfcf96f17ce0d71 Mon Sep 17 00:00:00 2001 From: Jan Holesovsky Date: Fri, 4 Oct 2019 11:01:31 +0200 Subject: lok preload: Some symbols are in-process when we need them. But OTOH in the preload case, the libraries we'd otherwise load are not there. An example was libcuilo.so where the instantiation of the spell checking dialog was failing, because it was impossible to find the makeSentenceEditWindow symbol. Change-Id: Ifc0bc5d8b295912728505fe3ce11fa4a0d198124 Reviewed-on: https://gerrit.libreoffice.org/80223 Tested-by: Jenkins CollaboraOffice Reviewed-by: Jan Holesovsky --- vcl/source/window/builder.cxx | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'vcl/source') diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index cdf5307646b8..ba93b26f98e1 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -47,8 +47,9 @@ #include #include #include +#include -#ifdef DISABLE_DYNLOADING +#if defined(DISABLE_DYNLOADING) || defined(LINUX) #include #endif @@ -1670,7 +1671,8 @@ VclPtr VclBuilder::makeObject(vcl::Window *pParent, const OString & sal_Int32 nDelim = name.indexOf('-'); if (nDelim != -1) { - OUString sFunction(OStringToOUString(OString("make") + name.copy(nDelim+1), RTL_TEXTENCODING_UTF8)); + OString aFunction(OString("make") + name.copy(nDelim+1)); + OUString sFunction(OStringToOUString(aFunction, RTL_TEXTENCODING_UTF8)); customMakeWidget pFunction = nullptr; #ifndef DISABLE_DYNLOADING @@ -1694,9 +1696,22 @@ VclPtr VclBuilder::makeObject(vcl::Window *pParent, const OString & { pModule.reset(new osl::Module); bool ok = pModule->loadRelative(&thisModule, sModule); - assert(ok && "bad module name in .ui"); - (void) ok; - pFunction = reinterpret_cast(pModule->getFunctionSymbol(sFunction)); +#ifdef LINUX + if (!ok && comphelper::LibreOfficeKit::isActive()) + { + // in the case of preloading, we don't have eg. the + // libcuilo.so, but still need to dlsym the symbols - + // which are already in-process + pFunction = reinterpret_cast(dlsym(RTLD_DEFAULT, aFunction.getStr())); + assert(pFunction && "couldn't even directly dlsym the sFunction (available via preload)"); + } + else +#endif + { + assert(ok && "bad module name in .ui"); + (void) ok; + pFunction = reinterpret_cast(pModule->getFunctionSymbol(sFunction)); + } } g_aModuleMap.insert(std::make_pair(sModule, pModule)); } -- cgit v1.2.3