diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-02-09 20:35:57 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-02-09 21:07:39 +0000 |
commit | b0a7722ebfa720255b6ce1e383a3aacae0ce5e9f (patch) | |
tree | 32ecc46f26b26068b2ba60dd09bb5b696cfcffca /framework | |
parent | 2234f541176cad8c7dcc3d732a898f701af979b4 (diff) |
coverity#1169848 Uncaught exception
Change-Id: I27903e8b6bbf28a33601d793719ac5bcd3309db0
Diffstat (limited to 'framework')
-rw-r--r-- | framework/source/services/modulemanager.cxx | 96 |
1 files changed, 53 insertions, 43 deletions
diff --git a/framework/source/services/modulemanager.cxx b/framework/source/services/modulemanager.cxx index 572fa9ff6515..d275e0a02355 100644 --- a/framework/source/services/modulemanager.cxx +++ b/framework/source/services/modulemanager.cxx @@ -278,55 +278,65 @@ void SAL_CALL ModuleManager::replaceByName(const OUString& sName , css::lang::WrappedTargetException , css::uno::RuntimeException ) { - ::comphelper::SequenceAsHashMap lProps(aValue); - if (lProps.empty() ) + try { - throw css::lang::IllegalArgumentException( - OUString("No properties given to replace part of module."), - static_cast< cppu::OWeakObject * >(this), - 2); - } + ::comphelper::SequenceAsHashMap lProps(aValue); + if (lProps.empty() ) + { + throw css::lang::IllegalArgumentException( + OUString("No properties given to replace part of module."), + static_cast< cppu::OWeakObject * >(this), + 2); + } - // SAFE -> ---------------------------------- - ReadGuard aReadLock(m_aLock); - css::uno::Reference< css::uno::XComponentContext > xContext = m_xContext; - aReadLock.unlock(); - // <- SAFE ---------------------------------- + // SAFE -> ---------------------------------- + ReadGuard aReadLock(m_aLock); + css::uno::Reference< css::uno::XComponentContext > xContext = m_xContext; + aReadLock.unlock(); + // <- SAFE ---------------------------------- + + // get access to the element + // Note: Dont use impl_getConfig() method here. Because it creates a readonly access only, further + // it cache it as a member of this module manager instance. If we change some props there ... but dont + // flush changes (because an error occurred) we will read them later. If we use a different config access + // we can close it without a flush ... and our read data wont be affected .-) + css::uno::Reference< css::uno::XInterface > xCfg = ::comphelper::ConfigurationHelper::openConfig( + xContext, + OUString(CFGPATH_FACTORIES), + ::comphelper::ConfigurationHelper::E_STANDARD); + css::uno::Reference< css::container::XNameAccess > xModules (xCfg, css::uno::UNO_QUERY_THROW); + css::uno::Reference< css::container::XNameReplace > xModule ; + + xModules->getByName(sName) >>= xModule; + if (!xModule.is()) + { + throw css::uno::RuntimeException( + OUString("Was not able to get write access to the requested module entry inside configuration."), + static_cast< cppu::OWeakObject * >(this)); + } - // get access to the element - // Note: Dont use impl_getConfig() method here. Because it creates a readonly access only, further - // it cache it as a member of this module manager instance. If we change some props there ... but dont - // flush changes (because an error occurred) we will read them later. If we use a different config access - // we can close it without a flush ... and our read data wont be affected .-) - css::uno::Reference< css::uno::XInterface > xCfg = ::comphelper::ConfigurationHelper::openConfig( - xContext, - OUString(CFGPATH_FACTORIES), - ::comphelper::ConfigurationHelper::E_STANDARD); - css::uno::Reference< css::container::XNameAccess > xModules (xCfg, css::uno::UNO_QUERY_THROW); - css::uno::Reference< css::container::XNameReplace > xModule ; - - xModules->getByName(sName) >>= xModule; - if (!xModule.is()) - { - throw css::uno::RuntimeException( - OUString("Was not able to get write access to the requested module entry inside configuration."), - static_cast< cppu::OWeakObject * >(this)); - } + ::comphelper::SequenceAsHashMap::const_iterator pProp; + for ( pProp = lProps.begin(); + pProp != lProps.end() ; + ++pProp ) + { + const OUString& sPropName = pProp->first; + const css::uno::Any& aPropValue = pProp->second; - ::comphelper::SequenceAsHashMap::const_iterator pProp; - for ( pProp = lProps.begin(); - pProp != lProps.end() ; - ++pProp ) - { - const OUString& sPropName = pProp->first; - const css::uno::Any& aPropValue = pProp->second; + // let "NoSuchElementException" out ! We support the same API ... + // and without a flush() at the end all changed data before will be ignored ! + xModule->replaceByName(sPropName, aPropValue); + } - // let "NoSuchElementException" out ! We support the same API ... - // and without a flush() at the end all changed data before will be ignored ! - xModule->replaceByName(sPropName, aPropValue); + ::comphelper::ConfigurationHelper::flush(xCfg); + } + catch (const css::beans::IllegalTypeException& e) + { + css::uno::Any a(e); + throw css::lang::WrappedTargetException( + OUString("ModuleManager::replaceByName: IllegalType exception"), + css::uno::Reference<css::uno::XInterface>(*this), a); } - - ::comphelper::ConfigurationHelper::flush(xCfg); } css::uno::Any SAL_CALL ModuleManager::getByName(const OUString& sName) |