comphelper/source/misc/configuration.cxx |   20 +++++++-------------
 include/comphelper/configuration.hxx     |   10 ++++------
 2 files changed, 11 insertions(+), 19 deletions(-)

New commits:
commit 4015b22dbc10bc246a3ef704d8b75e8f8cdca519
Author:     Stephan Bergmann <[email protected]>
AuthorDate: Fri Mar 11 08:04:03 2022 +0100
Commit:     Stephan Bergmann <[email protected]>
CommitDate: Fri Mar 11 09:49:03 2022 +0100

    Simplify ConfigurationWrapper singleton construction a bit
    
    Change-Id: I8b0dd0e049ebeb3304673df3bdb9fe7c755b7750
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131335
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <[email protected]>

diff --git a/comphelper/source/misc/configuration.cxx 
b/comphelper/source/misc/configuration.cxx
index 11c3f97ad1cd..a8ef15ac9178 100644
--- a/comphelper/source/misc/configuration.cxx
+++ b/comphelper/source/misc/configuration.cxx
@@ -41,12 +41,6 @@ namespace com::sun::star::uno { class XComponentContext; }
 
 namespace {
 
-comphelper::detail::ConfigurationWrapper& GetTheConfigurationWrapper()
-{
-    static comphelper::detail::ConfigurationWrapper 
WRAPPER(comphelper::getProcessComponentContext());
-    return WRAPPER;
-}
-
 OUString getDefaultLocale(
     css::uno::Reference< css::uno::XComponentContext > const & context)
 {
@@ -72,7 +66,7 @@ OUString extendLocalizedPath(std::u16string_view path, 
OUString const & locale)
 std::shared_ptr< comphelper::ConfigurationChanges >
 comphelper::ConfigurationChanges::create()
 {
-    return GetTheConfigurationWrapper().createChanges();
+    return detail::ConfigurationWrapper::get().createChanges();
 }
 
 comphelper::ConfigurationChanges::~ConfigurationChanges() {}
@@ -111,7 +105,8 @@ comphelper::ConfigurationChanges::getSet(OUString const & 
path) const
 comphelper::detail::ConfigurationWrapper const &
 comphelper::detail::ConfigurationWrapper::get()
 {
-    return GetTheConfigurationWrapper();
+    static comphelper::detail::ConfigurationWrapper WRAPPER;
+    return WRAPPER;
 }
 
 namespace
@@ -138,16 +133,15 @@ public:
 
 } // namespace
 
-comphelper::detail::ConfigurationWrapper::ConfigurationWrapper(
-    css::uno::Reference< css::uno::XComponentContext > const & context):
-    context_(context),
-    access_(css::configuration::ReadWriteAccess::create(context, "*"))
+comphelper::detail::ConfigurationWrapper::ConfigurationWrapper():
+    context_(comphelper::getProcessComponentContext()),
+    access_(css::configuration::ReadWriteAccess::create(context_, "*"))
 {
     // Set up a configuration notifier to invalidate the cache as needed.
     try
     {
         css::uno::Reference< css::lang::XMultiServiceFactory > xConfigProvider(
-            css::configuration::theDefaultProvider::get( context ) );
+            css::configuration::theDefaultProvider::get( context_ ) );
 
         // set root path
         css::uno::Sequence< css::uno::Any > params {
diff --git a/include/comphelper/configuration.hxx 
b/include/comphelper/configuration.hxx
index 8525b816a3c5..622c65e95e52 100644
--- a/include/comphelper/configuration.hxx
+++ b/include/comphelper/configuration.hxx
@@ -85,12 +85,6 @@ class COMPHELPER_DLLPUBLIC ConfigurationWrapper {
 public:
     static ConfigurationWrapper const & get();
 
-    SAL_DLLPRIVATE explicit ConfigurationWrapper(
-        css::uno::Reference< css::uno::XComponentContext >
-            const & context);
-
-    SAL_DLLPRIVATE ~ConfigurationWrapper();
-
     bool isReadOnly(OUString const & path) const;
 
     css::uno::Any getPropertyValue(OUString const & path) const;
@@ -127,6 +121,10 @@ public:
     std::shared_ptr< ConfigurationChanges > createChanges() const;
 
 private:
+    SAL_DLLPRIVATE explicit ConfigurationWrapper();
+
+    SAL_DLLPRIVATE ~ConfigurationWrapper();
+
     ConfigurationWrapper(const ConfigurationWrapper&) = delete;
     ConfigurationWrapper& operator=(const ConfigurationWrapper&) = delete;
 

Reply via email to