Work around premature disposing of PackageRegistryBackends
With ucbhelper::Content now requiring an XComponentContext during construction, calling "unopkg add" with an .oxt that requires license acceptance would lead to an assertion about a null XComponentContext, as doChecksForAddExtension calls the XPackage's checkPrerequisites -> checkLicnese -> getTextFromURL, which creates an ucbhelper::Content with getMyBackend()->getComponentContext(), but early release of the "tmp" manager would already have caused disposing of that backend, which clears m_xComponentContext. I assume this problem had always been lurking silently in the code. Change-Id: I9f59c612fe3831b2f6dd832ef2f0505b6590b8e0
This commit is contained in:
parent
89e875b50a
commit
c9a27eb938
@ -655,8 +655,22 @@ Reference<deploy::XPackage> ExtensionManager::addExtension(
|
||||
//would remove the first one.
|
||||
::osl::MutexGuard addGuard(m_addMutex);
|
||||
|
||||
Reference<deploy::XPackage> xTmpExtension =
|
||||
getTempExtension(url, xAbortChannel, xCmdEnv);
|
||||
Reference<deploy::XPackageManager> xTmpRepository(getTmpRepository());
|
||||
// make sure xTmpRepository is alive as long as xTmpExtension is; as
|
||||
// the "tmp" manager is only held weakly by m_xPackageManagerFactory, it
|
||||
// could otherwise be disposed early, which would in turn dispose
|
||||
// xTmpExtension's PackageRegistryBackend behind its back
|
||||
Reference<deploy::XPackage> xTmpExtension(
|
||||
xTmpRepository->addPackage(
|
||||
url, uno::Sequence<beans::NamedValue>(), OUString(), xAbortChannel,
|
||||
new TmpRepositoryCommandEnv()));
|
||||
if (!xTmpExtension.is()) {
|
||||
throw deploy::DeploymentException(
|
||||
("Extension Manager: Failed to create temporary XPackage for url: "
|
||||
+ url),
|
||||
static_cast<OWeakObject*>(this), uno::Any());
|
||||
}
|
||||
|
||||
//Make sure the extension is removed from the tmp repository in case
|
||||
//of an exception
|
||||
ExtensionRemoveGuard tmpExtensionRemoveGuard(xTmpExtension, getTmpRepository());
|
||||
@ -1404,25 +1418,6 @@ void ExtensionManager::checkUpdate(
|
||||
static_cast<OWeakObject *>(this), request );
|
||||
}
|
||||
|
||||
Reference<deploy::XPackage> ExtensionManager::getTempExtension(
|
||||
OUString const & url,
|
||||
Reference<task::XAbortChannel> const & xAbortChannel,
|
||||
Reference<ucb::XCommandEnvironment> const & /*xCmdEnv*/)
|
||||
|
||||
{
|
||||
Reference<ucb::XCommandEnvironment> tmpCmdEnvA(new TmpRepositoryCommandEnv());
|
||||
Reference<deploy::XPackage> xTmpPackage = getTmpRepository()->addPackage(
|
||||
url, uno::Sequence<beans::NamedValue>(),OUString(), xAbortChannel, tmpCmdEnvA);
|
||||
if (!xTmpPackage.is())
|
||||
{
|
||||
throw deploy::DeploymentException(
|
||||
OUSTR("Extension Manager: Failed to create temporary XPackage for url: ") + url,
|
||||
static_cast<OWeakObject*>(this), uno::Any());
|
||||
|
||||
}
|
||||
return xTmpPackage;
|
||||
}
|
||||
|
||||
uno::Sequence<Reference<deploy::XPackage> > SAL_CALL
|
||||
ExtensionManager::getExtensionsWithUnacceptedLicenses(
|
||||
OUString const & repository,
|
||||
|
@ -280,11 +280,6 @@ private:
|
||||
css::uno::Reference<css::deployment::XPackage> const & oldExtension,
|
||||
css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv);
|
||||
|
||||
css::uno::Reference<css::deployment::XPackage> getTempExtension(
|
||||
::rtl::OUString const & url,
|
||||
css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel,
|
||||
css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv);
|
||||
|
||||
void addExtensionsToMap(
|
||||
id2extensions & mapExt,
|
||||
css::uno::Sequence<css::uno::Reference<css::deployment::XPackage> > const & seqExt,
|
||||
|
Loading…
x
Reference in New Issue
Block a user