diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2021-03-21 13:25:15 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-03-22 16:05:07 +0100 |
commit | cd596ebc8ecc1ac303c4c3481c541cb52afa32bb (patch) | |
tree | 2e1865507f68dc347c371f07a7e53ff3ed85e604 /framework/source | |
parent | 4566bcbf03c1b7b0c1ce3a83fee1d195f0ff7059 (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>
Diffstat (limited to 'framework/source')
-rw-r--r-- | framework/source/services/pathsettings.cxx | 27 |
1 files changed, 6 insertions, 21 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: */ |