use single-use attribute for OfficeInstallationDirectories

instead of rtl::Instance, which means it will get
cleaned up when UNO shuts down

Change-Id: If6b0a41d0a8a20ea4989771d83833288c6bd3234
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112926
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2021-03-22 13:31:00 +02:00 committed by Noel Grandin
parent 5947744bd7
commit fb6443a17d
2 changed files with 4 additions and 21 deletions

View file

@ -236,32 +236,14 @@ void OfficeInstallationDirectories::initDirs()
}
namespace {
struct Instance {
explicit Instance(
css::uno::Reference<css::uno::XComponentContext> const & context):
instance(static_cast<cppu::OWeakObject *>(
new comphelper::OfficeInstallationDirectories(context)))
{}
rtl::Reference<css::uno::XInterface> instance;
};
struct Singleton:
public rtl::StaticWithArg<
Instance, css::uno::Reference<css::uno::XComponentContext>, Singleton>
{};
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
com_sun_star_comp_util_OfficeInstallationDirectories(
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &)
{
return cppu::acquire(static_cast<cppu::OWeakObject *>(
Singleton::get(context).instance.get()));
return cppu::acquire(
new comphelper::OfficeInstallationDirectories(context));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View file

@ -58,7 +58,8 @@
<singleton name="com.sun.star.task.OfficeRestartManager"/>
</implementation>
<implementation name="com.sun.star.comp.util.OfficeInstallationDirectories"
constructor="com_sun_star_comp_util_OfficeInstallationDirectories">
constructor="com_sun_star_comp_util_OfficeInstallationDirectories"
single-instance="true">
<service name="com.sun.star.util.OfficeInstallationDirectories"/>
<singleton name="com.sun.star.util.theOfficeInstallationDirectories"/>
</implementation>