summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2021-03-21 13:25:15 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-03-22 16:05:07 +0100
commitcd596ebc8ecc1ac303c4c3481c541cb52afa32bb (patch)
tree2e1865507f68dc347c371f07a7e53ff3ed85e604
parent4566bcbf03c1b7b0c1ce3a83fee1d195f0ff7059 (diff)
use single-use attribute for PathSettings
instead of rtl::Instance, which means it will get cleaned up when UNO shuts down Change-Id: I90f7e0af8ce67cdcef2df7b28c7e55b1c92aad3a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112834 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--framework/source/services/pathsettings.cxx27
-rw-r--r--framework/util/fwk.component3
2 files changed, 8 insertions, 22 deletions
diff --git a/framework/source/services/pathsettings.cxx b/framework/source/services/pathsettings.cxx
index c59ef728ccb5..b58091294231 100644
--- a/framework/source/services/pathsettings.cxx
+++ b/framework/source/services/pathsettings.cxx
@@ -40,6 +40,7 @@
#include <tools/urlobj.hxx>
#include <rtl/ustrbuf.hxx>
+#include <rtl/ref.hxx>
#include <sal/log.hxx>
#include <cppuhelper/basemutex.hxx>
@@ -1409,25 +1410,6 @@ css::uno::Reference< css::container::XNameAccess > PathSettings::fa_getCfgNew()
return xCfg;
}
-struct Instance {
- explicit Instance(
- css::uno::Reference<css::uno::XComponentContext> const & context):
- instance(
- static_cast<cppu::OWeakObject *>(new PathSettings(context)))
- {
- // fill cache
- static_cast<PathSettings *>(static_cast<cppu::OWeakObject *>
- (instance.get()))->impl_readAll();
- }
-
- css::uno::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 *
@@ -1435,8 +1417,11 @@ com_sun_star_comp_framework_PathSettings_get_implementation(
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &)
{
- return cppu::acquire(static_cast<cppu::OWeakObject *>(
- Singleton::get(context).instance.get()));
+ rtl::Reference<PathSettings> xPathSettings = new PathSettings(context);
+ // fill cache
+ xPathSettings->impl_readAll();
+
+ return cppu::acquire(xPathSettings.get());
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/util/fwk.component b/framework/util/fwk.component
index c20c9a30c0e2..d695aef4841a 100644
--- a/framework/util/fwk.component
+++ b/framework/util/fwk.component
@@ -104,7 +104,8 @@
<service name="com.sun.star.frame.PopupMenuController"/>
</implementation>
<implementation name="com.sun.star.comp.framework.PathSettings"
- constructor="com_sun_star_comp_framework_PathSettings_get_implementation">
+ constructor="com_sun_star_comp_framework_PathSettings_get_implementation"
+ single-instance="true">
<service name="com.sun.star.util.PathSettings"/>
<singleton name="com.sun.star.util.thePathSettings"/>
</implementation>