[Libreoffice-commits] .: 2 commits - configmgr/source framework/source

Caolán McNamara caolan at kemper.freedesktop.org
Tue Oct 19 05:36:39 PDT 2010


 configmgr/source/components.cxx                  |    2 +-
 framework/source/services/pathsettings.cxx       |   22 +++++++++++++---------
 framework/source/services/substitutepathvars.cxx |   23 +++++++++++++++++++++--
 3 files changed, 35 insertions(+), 12 deletions(-)

New commits:
commit 5da353cab7576e38025eb5ec6fad3d25ba0d6175
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Oct 19 11:28:01 2010 +0100

    survive missing configuration entries gracefully

diff --git a/framework/source/services/pathsettings.cxx b/framework/source/services/pathsettings.cxx
index 76ecd86..46f7d16 100644
--- a/framework/source/services/pathsettings.cxx
+++ b/framework/source/services/pathsettings.cxx
@@ -223,17 +223,21 @@ void PathSettings::impl_readAll()
     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen at sun.com", "PathSettings::impl_readAll" );
     RTL_LOGFILE_CONTEXT(aLog, "framework (as96863) ::PathSettings::load config (all)");
 
-    // TODO think about me
-    css::uno::Reference< css::container::XNameAccess > xCfg    = fa_getCfgNew();
-    css::uno::Sequence< ::rtl::OUString >              lPaths = xCfg->getElementNames();
-
-    sal_Int32 c = lPaths.getLength();
-    sal_Int32 i = 0;
+    try
+    {
+        // TODO think about me
+        css::uno::Reference< css::container::XNameAccess > xCfg    = fa_getCfgNew();
+        css::uno::Sequence< ::rtl::OUString >              lPaths = xCfg->getElementNames();
 
-    for (i=0; i<c; ++i)
+        sal_Int32 c = lPaths.getLength();
+        for (sal_Int32 i = 0; i < c; ++i)
+        {
+            const ::rtl::OUString& sPath = lPaths[i];
+            impl_updatePath(sPath, sal_False);
+        }
+    }
+    catch(const css::uno::RuntimeException& )
     {
-        const ::rtl::OUString& sPath = lPaths[i];
-        impl_updatePath(sPath, sal_False);
     }
 
     impl_rebuildPropertyDescriptor();
diff --git a/framework/source/services/substitutepathvars.cxx b/framework/source/services/substitutepathvars.cxx
index 6013f7d..bb67b75 100644
--- a/framework/source/services/substitutepathvars.cxx
+++ b/framework/source/services/substitutepathvars.cxx
@@ -718,12 +718,24 @@ rtl::OUString SubstitutePathVariables::GetWorkPath() const
 {
     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen at sun.com", "SubstitutePathVariables::GetWorkPath" );
     rtl::OUString aWorkPath;
-    ::comphelper::ConfigurationHelper::readDirectKey(
+
+    try
+    {
+        ::comphelper::ConfigurationHelper::readDirectKey(
                             m_xServiceManager,
                             ::rtl::OUString::createFromAscii("org.openoffice.Office.Paths"),
                             ::rtl::OUString::createFromAscii("Paths/Work"),
                             ::rtl::OUString::createFromAscii("WritePath"),
                             ::comphelper::ConfigurationHelper::E_READONLY) >>= aWorkPath;
+    }
+    catch(RuntimeException &)
+    {
+    }
+
+    // fallback in case config layer does not return an useable work dir value.
+    if (aWorkPath.getLength() < 1)
+        aWorkPath = GetWorkVariableValue();
+
     return aWorkPath;
 }
 
@@ -731,12 +743,19 @@ rtl::OUString SubstitutePathVariables::GetWorkVariableValue() const
 {
     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen at sun.com", "SubstitutePathVariables::GetWorkVariableValue" );
     ::rtl::OUString aWorkPath;
-    ::comphelper::ConfigurationHelper::readDirectKey(
+
+    try
+    {
+        ::comphelper::ConfigurationHelper::readDirectKey(
                             m_xServiceManager,
                             ::rtl::OUString::createFromAscii("org.openoffice.Office.Paths"),
                             ::rtl::OUString::createFromAscii("Variables"),
                             ::rtl::OUString::createFromAscii("Work"),
                             ::comphelper::ConfigurationHelper::E_READONLY) >>= aWorkPath;
+    }
+    catch(RuntimeException &)
+    {
+    }
     
     // fallback to $HOME in  case platform dependend config layer does not return
     // an usuable work dir value.
commit c7738b754d25994449a390fc8ef5fedf546f6b96
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Oct 19 08:52:55 2010 +0100

    don't set singletonCreated before possible throws

diff --git a/configmgr/source/components.cxx b/configmgr/source/components.cxx
index ae0da5f..f76f020 100644
--- a/configmgr/source/components.cxx
+++ b/configmgr/source/components.cxx
@@ -154,9 +154,9 @@ void Components::initSingleton(
 {
     OSL_ASSERT(context.is());
     if (!singletonCreated) {
-        singletonCreated = true;
         static Components theSingleton(context);
         singleton = &theSingleton;
+        singletonCreated = true;
     }
 }
 


More information about the Libreoffice-commits mailing list