summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Monastirsky <momonasmon@gmail.com>2017-02-19 11:56:37 +0200
committerMaxim Monastirsky <momonasmon@gmail.com>2017-02-21 01:40:08 +0200
commit8c5a3b448a50981b41b2860c64a3039265398cf9 (patch)
tree30d04d250233e1bcc7825f4655a6ce8b66f533db
parent7e559e549528686d431056bd1bbbc9c0a0bfb304 (diff)
Single GlobalAcceleratorConfiguration should be enough
avoid reading the configuration again and again. Change-Id: I4179da53114990e5ee68b47125ccef356ca00d53
-rw-r--r--framework/source/accelerators/globalacceleratorconfiguration.cxx23
1 files changed, 17 insertions, 6 deletions
diff --git a/framework/source/accelerators/globalacceleratorconfiguration.cxx b/framework/source/accelerators/globalacceleratorconfiguration.cxx
index ba5a2e407b8e..d8d1f859ceb7 100644
--- a/framework/source/accelerators/globalacceleratorconfiguration.cxx
+++ b/framework/source/accelerators/globalacceleratorconfiguration.cxx
@@ -111,6 +111,22 @@ void GlobalAcceleratorConfiguration::fillCache()
{}
}
+struct Instance
+{
+ explicit Instance(css::uno::Reference<css::uno::XComponentContext> const & context)
+ : instance(new GlobalAcceleratorConfiguration(context))
+ {
+ instance->fillCache();
+ }
+
+ rtl::Reference<GlobalAcceleratorConfiguration> instance;
+};
+
+struct Singleton:
+ public rtl::StaticWithArg<
+ Instance, css::uno::Reference<css::uno::XComponentContext>, Singleton>
+{};
+
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
@@ -118,12 +134,7 @@ com_sun_star_comp_framework_GlobalAcceleratorConfiguration_get_implementation(
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &)
{
- GlobalAcceleratorConfiguration *inst = new GlobalAcceleratorConfiguration(context);
- css::uno::XInterface *acquired_inst = cppu::acquire(inst);
-
- inst->fillCache();
-
- return acquired_inst;
+ return cppu::acquire(static_cast<cppu::OWeakObject*>(Singleton::get(context).instance.get()));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */