diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2019-03-29 09:51:39 +0000 |
---|---|---|
committer | Aron Budea <aron.budea@collabora.com> | 2019-11-22 17:30:35 +0100 |
commit | 520b18dd21cbcd923def62b042f20f234447fea1 (patch) | |
tree | 409d8231f9b844aaf101bb1b44948375ef60f08a /cppuhelper | |
parent | 58ef4b593bba3d592e07e0f25140808c74f8aa0f (diff) |
preload: cleanup disabled messages and simplify flow.
Change-Id: I249b81afe5ec2fab5e0aaf73a2cde62173fa803e
Reviewed-on: https://gerrit.libreoffice.org/69912
Tested-by: Jenkins
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/83473
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Aron Budea <aron.budea@collabora.com>
Diffstat (limited to 'cppuhelper')
-rw-r--r-- | cppuhelper/source/servicemanager.cxx | 190 |
1 files changed, 93 insertions, 97 deletions
diff --git a/cppuhelper/source/servicemanager.cxx b/cppuhelper/source/servicemanager.cxx index 69ecc4d4ac6c..a2f78cf9b41f 100644 --- a/cppuhelper/source/servicemanager.cxx +++ b/cppuhelper/source/servicemanager.cxx @@ -1791,7 +1791,7 @@ void cppuhelper::ServiceManager::preloadImplementations() { std::cerr << "preload:"; std::vector<OUString> aReported; std::vector<OUString> aDisabled; - OUStringBuffer aDisabledMsg("Disabled: "); + OUStringBuffer aDisabledMsg; /// Allow external callers & testers to disable certain components const char *pDisable = getenv("UNODISABLELIBRARY"); @@ -1810,6 +1810,10 @@ void cppuhelper::ServiceManager::preloadImplementations() { // loop all implementations for (const auto& rEntry : data_.namedImplementations) { + if (rEntry.second->info->loader != "com.sun.star.loader.SharedLibrary" || + rEntry.second->status == Data::Implementation::STATUS_LOADED) + continue; + try { const OUString &aLibrary = rEntry.second->info->uri; @@ -1849,126 +1853,118 @@ void cppuhelper::ServiceManager::preloadImplementations() { static_cast< cppu::OWeakObject * >(this)); } - if (rEntry.second->info->loader == "com.sun.star.loader.SharedLibrary" && - rEntry.second->status != Data::Implementation::STATUS_LOADED) + // Blacklist some components that are known to fail + if (rEntry.second->info->name == "com.sun.star.comp.configuration.backend.KDE4Backend") { - // Blacklist some components that are known to fail - if (iterator->second->info->name == "com.sun.star.comp.configuration.backend.KDE4Backend") - { - std::cerr << ":skipping"; - std::cerr.flush(); - continue; - } + std::cerr << ":skipping"; + std::cerr.flush(); + continue; + } - // load component library - osl::Module aModule(aUri, SAL_LOADMODULE_NOW | SAL_LOADMODULE_GLOBAL); + // load component library + osl::Module aModule(aUri, SAL_LOADMODULE_NOW | SAL_LOADMODULE_GLOBAL); - if (!aModule.is()) - { - std::cerr << ":failed" << std::endl; - std::cerr.flush(); - } + if (!aModule.is()) + { + std::cerr << ":failed" << std::endl; + std::cerr.flush(); + } + + if (aModule.is() && + !rEntry.second->info->environment.isEmpty()) + { + OUString aSymFactory; + oslGenericFunction fpFactory; + css::uno::Environment aTargetEnv; + css::uno::Reference<css::uno::XInterface> xFactory; - if (aModule.is() && - !rEntry.second->info->environment.isEmpty()) + if(rEntry.second->info->constructor.isEmpty()) { - OUString aSymFactory; - oslGenericFunction fpFactory; - css::uno::Environment aTargetEnv; - css::uno::Reference<css::uno::XInterface> xFactory; + // expand full name component factory symbol + if (rEntry.second->info->prefix == "direct") + aSymFactory = rEntry.second->info->name.replace('.', '_') + "_" COMPONENT_GETFACTORY; + else if (!rEntry.second->info->prefix.isEmpty()) + aSymFactory = rEntry.second->info->prefix + "_" COMPONENT_GETFACTORY; + else + aSymFactory = COMPONENT_GETFACTORY; - if(rEntry.second->info->constructor.isEmpty()) + // get function symbol component factory + fpFactory = aModule.getFunctionSymbol(aSymFactory); + if (fpFactory == nullptr) { - // expand full name component factory symbol - if (rEntry.second->info->prefix == "direct") - aSymFactory = rEntry.second->info->name.replace('.', '_') + "_" COMPONENT_GETFACTORY; - else if (!rEntry.second->info->prefix.isEmpty()) - aSymFactory = rEntry.second->info->prefix + "_" COMPONENT_GETFACTORY; - else - aSymFactory = COMPONENT_GETFACTORY; - - // get function symbol component factory - fpFactory = aModule.getFunctionSymbol(aSymFactory); - if (fpFactory == nullptr) - { - throw css::loader::CannotActivateFactoryException( - ("no factory symbol \"" + aSymFactory + "\" in component library :" + aUri), - css::uno::Reference<css::uno::XInterface>()); - } - - aTargetEnv = cppuhelper::detail::getEnvironment(rEntry.second->info->environment, rEntry.second->info->name); - component_getFactoryFunc fpComponentFactory = reinterpret_cast<component_getFactoryFunc>(fpFactory); - - if (aSourceEnv.get() == aTargetEnv.get()) - { - // invoke function component factory - OString aImpl(OUStringToOString(rEntry.second->info->name, RTL_TEXTENCODING_ASCII_US)); - xFactory.set(css::uno::Reference<css::uno::XInterface>(static_cast<css::uno::XInterface *>( - (*fpComponentFactory)(aImpl.getStr(), this, nullptr)), SAL_NO_ACQUIRE)); - } + throw css::loader::CannotActivateFactoryException( + ("no factory symbol \"" + aSymFactory + "\" in component library :" + aUri), + css::uno::Reference<css::uno::XInterface>()); } - else + + aTargetEnv = cppuhelper::detail::getEnvironment(rEntry.second->info->environment, rEntry.second->info->name); + component_getFactoryFunc fpComponentFactory = reinterpret_cast<component_getFactoryFunc>(fpFactory); + + if (aSourceEnv.get() == aTargetEnv.get()) { - // get function symbol component factory - aTargetEnv = cppuhelper::detail::getEnvironment(rEntry.second->info->environment, rEntry.second->info->name); - if (aSourceEnv.get() == aTargetEnv.get()) - { - fpFactory = aModule.getFunctionSymbol(rEntry.second->info->constructor); - } - else - { - fpFactory = nullptr; - } + // invoke function component factory + OString aImpl(OUStringToOString(rEntry.second->info->name, RTL_TEXTENCODING_ASCII_US)); + xFactory.set(css::uno::Reference<css::uno::XInterface>(static_cast<css::uno::XInterface *>( + (*fpComponentFactory)(aImpl.getStr(), this, nullptr)), SAL_NO_ACQUIRE)); } + } + else + { + // get function symbol component factory + aTargetEnv = cppuhelper::detail::getEnvironment(rEntry.second->info->environment, rEntry.second->info->name); + fpFactory = (aSourceEnv.get() == aTargetEnv.get()) ? + aModule.getFunctionSymbol(rEntry.second->info->constructor) : nullptr; + } - css::uno::Reference<css::lang::XSingleComponentFactory> xSCFactory; - css::uno::Reference<css::lang::XSingleServiceFactory> xSSFactory; + css::uno::Reference<css::lang::XSingleComponentFactory> xSCFactory; + css::uno::Reference<css::lang::XSingleServiceFactory> xSSFactory; - // query interface XSingleComponentFactory or XSingleServiceFactory - if (xFactory.is()) + // query interface XSingleComponentFactory or XSingleServiceFactory + if (xFactory.is()) + { + xSCFactory.set(xFactory, css::uno::UNO_QUERY); + if (!xSCFactory.is()) { - xSCFactory.set(xFactory, css::uno::UNO_QUERY); - if (!xSCFactory.is()) - { - xSSFactory.set(xFactory, css::uno::UNO_QUERY); - if (!xSSFactory.is()) - { - throw css::uno::DeploymentException( - ("Implementation " + rEntry.second->info->name - + " does not provide a constructor or factory"), - static_cast< cppu::OWeakObject * >(this)); - } - } + xSSFactory.set(xFactory, css::uno::UNO_QUERY); + if (!xSSFactory.is()) + throw css::uno::DeploymentException( + ("Implementation " + rEntry.second->info->name + + " does not provide a constructor or factory"), + static_cast< cppu::OWeakObject * >(this)); } + } - if (!rEntry.second->info->constructor.isEmpty() && fpFactory) - rEntry.second->constructor = WrapperConstructorFn(reinterpret_cast<ImplementationConstructorFn *>(fpFactory)); + if (!rEntry.second->info->constructor.isEmpty() && fpFactory) + rEntry.second->constructor = WrapperConstructorFn(reinterpret_cast<ImplementationConstructorFn *>(fpFactory)); - rEntry.second->factory1 = xSCFactory; - rEntry.second->factory2 = xSSFactory; - rEntry.second->status = Data::Implementation::STATUS_LOADED; + rEntry.second->factory1 = xSCFactory; + rEntry.second->factory2 = xSSFactory; + rEntry.second->status = Data::Implementation::STATUS_LOADED; - } + } - // Some libraries use other (non-UNO) libraries requiring preinit - oslGenericFunction fpPreload = aModule.getFunctionSymbol( "lok_preload_hook" ); - if (fpPreload) + // Some libraries use other (non-UNO) libraries requiring preinit + oslGenericFunction fpPreload = aModule.getFunctionSymbol( "lok_preload_hook" ); + if (fpPreload) + { + static std::vector<oslGenericFunction> aPreloaded; + if (std::find(aPreloaded.begin(), aPreloaded.end(), fpPreload) == aPreloaded.end()) { - static std::vector<oslGenericFunction> aPreloaded; - if (std::find(aPreloaded.begin(), aPreloaded.end(), fpPreload) == aPreloaded.end()) - { - aPreloaded.push_back(fpPreload); - fpPreload(); - } + aPreloaded.push_back(fpPreload); + fpPreload(); } - - // leak aModule - aModule.release(); } + + // leak aModule + aModule.release(); } std::cerr << std::endl; - std::cerr << aDisabledMsg.makeStringAndClear() << "\n"; + if (aDisabledMsg.getLength() > 0) + { + OUString aMsg = aDisabledMsg.makeStringAndClear(); + std::cerr << "Disabled: " << aMsg << "\n"; + } std::cerr.flush(); // Various rather important uno mappings. |