diff options
Diffstat (limited to 'desktop/source/deployment/registry/package')
-rw-r--r-- | desktop/source/deployment/registry/package/dp_package.cxx | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/desktop/source/deployment/registry/package/dp_package.cxx b/desktop/source/deployment/registry/package/dp_package.cxx index 321db824f40c..494ce437e1e9 100644 --- a/desktop/source/deployment/registry/package/dp_package.cxx +++ b/desktop/source/deployment/registry/package/dp_package.cxx @@ -32,6 +32,7 @@ #include <rtl/uri.hxx> #include <rtl/ustrbuf.hxx> #include <sal/log.hxx> +#include <o3tl/string_view.hxx> #include <cppuhelper/exc_hlp.hxx> #include <cppuhelper/implbase.hxx> #include <cppuhelper/supportsservice.hxx> @@ -67,11 +68,12 @@ #include <com/sun/star/deployment/PlatformException.hpp> #include <com/sun/star/deployment/Prerequisites.hpp> #include <optional> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <algorithm> #include <memory> #include <string_view> +#include <utility> #include <vector> #include "dp_extbackenddb.hxx" @@ -252,7 +254,7 @@ class XPackage_eq { OUString m_URL; public: - explicit XPackage_eq(const OUString & s) : m_URL(s) {} + explicit XPackage_eq(OUString s) : m_URL(std::move(s)) {} bool operator() (const Reference<deployment::XPackage> & p) const { return m_URL == p->getURL(); @@ -307,7 +309,7 @@ sal_Bool BackendImpl::supportsService(OUString const & ServiceName) Sequence<OUString> BackendImpl::getSupportedServiceNames() { - return { OUString(BACKEND_SERVICE_NAME) }; + return { BACKEND_SERVICE_NAME }; } // XPackageRegistry @@ -779,7 +781,7 @@ uno::Reference< graphic::XGraphic > BackendImpl::PackageImpl::getIcon( sal_Bool void BackendImpl::PackageImpl::processPackage_( - ::osl::ResettableMutexGuard &, + ::osl::ResettableMutexGuard & guard, bool doRegisterPackage, bool startup, ::rtl::Reference<AbortChannel> const & abortChannel, @@ -800,6 +802,13 @@ void BackendImpl::PackageImpl::processPackage_( xPackage->createAbortChannel() ); AbortChannel::Chain chain( abortChannel, xSubAbortChannel ); try { + // tdf#159790 temporarily release mutex for child packages + // This code is normally run on a separate thread so if a + // child package tries to acquire the solar mutex, a deadlock + // can occur if the main thread calls isRegistered() on this + // package or any of its parents. So, temporarily release + // this package's mutex while registering the child package. + osl::ResettableMutexGuardScopedReleaser releaser(guard); xPackage->registerPackage( startup, xSubAbortChannel, xCmdEnv ); } catch (const Exception &) @@ -854,6 +863,7 @@ void BackendImpl::PackageImpl::processPackage_( ::cppu::throwException(exc); } } + data.items.emplace_back(xPackage->getURL(), xPackage->getPackageType()->getMediaType()); } @@ -1055,9 +1065,9 @@ void BackendImpl::PackageImpl::exportTo( manifest.reserve( bundle.getLength() ); sal_Int32 baseURLlen = m_url_expanded.getLength(); Reference<deployment::XPackage> const *pbundle = bundle.getConstArray(); - static const OUStringLiteral strMediaType( u"MediaType" ); - static const OUStringLiteral strFullPath( u"FullPath" ); - static const OUStringLiteral strIsFolder( u"IsFolder" ); + static constexpr OUStringLiteral strMediaType( u"MediaType" ); + static constexpr OUStringLiteral strFullPath( u"FullPath" ); + static constexpr OUStringLiteral strIsFolder( u"IsFolder" ); for ( sal_Int32 pos = bundle.getLength(); pos--; ) { Reference<deployment::XPackage> const & xPackage = pbundle[ pos ]; @@ -1265,12 +1275,12 @@ Sequence< Reference<deployment::XPackage> > BackendImpl::PackageImpl::getBundle( return *pBundle; } -bool isBundle_( OUString const & mediaType ) +bool isBundle_( std::u16string_view mediaType ) { // xxx todo: additional parsing? - return !mediaType.isEmpty() && - (mediaType.matchIgnoreAsciiCase( "application/vnd.sun.star.package-bundle") || - mediaType.matchIgnoreAsciiCase( "application/vnd.sun.star.legacy-package-bundle")); + return !mediaType.empty() && + (o3tl::matchIgnoreAsciiCase( mediaType, u"application/vnd.sun.star.package-bundle") || + o3tl::matchIgnoreAsciiCase( mediaType, u"application/vnd.sun.star.legacy-package-bundle")); } @@ -1381,7 +1391,7 @@ void BackendImpl::PackageImpl::scanBundle( continue; { - auto const iter = params.find("platform"); + auto const iter = params.find("platform"_ostr); if (iter != params.end() && !platform_fits(iter->second.m_sValue)) continue; } @@ -1392,7 +1402,7 @@ void BackendImpl::PackageImpl::scanBundle( subType.equalsIgnoreAsciiCase( "vnd.sun.star.package-bundle-description")) { // check locale: - auto const iter = params.find("locale"); + auto const iter = params.find("locale"_ostr); if (iter == params.end()) { if (descrFile.isEmpty()) @@ -1487,7 +1497,7 @@ void BackendImpl::PackageImpl::scanLegacyBundle( // check for platform paths: const OUString title( StrTitle::getTitle( ucbContent ) ); if (title.endsWithIgnoreAsciiCase( ".plt" ) && - !platform_fits( title.copy( 0, title.getLength() - 4 ) )) { + !platform_fits( title.subView( 0, title.getLength() - 4 ) )) { return; } if (title.endsWithIgnoreAsciiCase("skip_registration") ) |