cppuhelper/source/component_context.cxx | 4 - framework/source/uifactory/uielementfactorymanager.cxx | 47 ++++++++----- framework/source/uifactory/windowcontentfactorymanager.cxx | 33 +++------ i18npool/inc/numberformatcode.hxx | 1 i18npool/source/numberformatcode/numberformatcode.cxx | 4 + 5 files changed, 51 insertions(+), 38 deletions(-)
New commits: commit d01888302b03a79bf7ccde6cbe8434b427164a75 Author: Stephan Bergmann <[email protected]> Date: Mon Jan 4 14:22:59 2016 +0100 tdf#82775: Make NumberFormatCodeMapper MT safe Change-Id: I77f49f09ce9fe5897f78044c0522210978c904d1 diff --git a/i18npool/inc/numberformatcode.hxx b/i18npool/inc/numberformatcode.hxx index 3b36cec..9c7d780 100644 --- a/i18npool/inc/numberformatcode.hxx +++ b/i18npool/inc/numberformatcode.hxx @@ -54,6 +54,7 @@ public: throw( css::uno::RuntimeException, std::exception ) override; private: + osl::Mutex maMutex; css::lang::Locale aLocale; css::uno::Reference < css::uno::XComponentContext > mxContext; css::uno::Sequence< css::i18n::FormatElement > aFormatSeq; diff --git a/i18npool/source/numberformatcode/numberformatcode.cxx b/i18npool/source/numberformatcode/numberformatcode.cxx index 76beead..e329589 100644 --- a/i18npool/source/numberformatcode/numberformatcode.cxx +++ b/i18npool/source/numberformatcode/numberformatcode.cxx @@ -44,6 +44,7 @@ NumberFormatCodeMapper::getDefault( sal_Int16 formatType, sal_Int16 formatUsage, OUString elementType = mapElementTypeShortToString(formatType); OUString elementUsage = mapElementUsageShortToString(formatUsage); + osl::MutexGuard g(maMutex); getFormats( rLocale ); for(sal_Int32 i = 0; i < aFormatSeq.getLength(); i++) { @@ -68,6 +69,7 @@ NumberFormatCodeMapper::getDefault( sal_Int16 formatType, sal_Int16 formatUsage, css::i18n::NumberFormatCode SAL_CALL NumberFormatCodeMapper::getFormatCode( sal_Int16 formatIndex, const css::lang::Locale& rLocale ) throw(css::uno::RuntimeException, std::exception) { + osl::MutexGuard g(maMutex); getFormats( rLocale ); for(sal_Int32 i = 0; i < aFormatSeq.getLength(); i++) { @@ -92,6 +94,7 @@ NumberFormatCodeMapper::getFormatCode( sal_Int16 formatIndex, const css::lang::L css::uno::Sequence< css::i18n::NumberFormatCode > SAL_CALL NumberFormatCodeMapper::getAllFormatCode( sal_Int16 formatUsage, const css::lang::Locale& rLocale ) throw(css::uno::RuntimeException, std::exception) { + osl::MutexGuard g(maMutex); getFormats( rLocale ); sal_Int32 i, count; @@ -125,6 +128,7 @@ NumberFormatCodeMapper::getAllFormatCode( sal_Int16 formatUsage, const css::lang css::uno::Sequence< css::i18n::NumberFormatCode > SAL_CALL NumberFormatCodeMapper::getAllFormatCodes( const css::lang::Locale& rLocale ) throw(css::uno::RuntimeException, std::exception) { + osl::MutexGuard g(maMutex); getFormats( rLocale ); css::uno::Sequence<css::i18n::NumberFormatCode> seq(aFormatSeq.getLength()); commit e83f31724e0f2cd4242e0b398c48578da53cb5c1 Author: Stephan Bergmann <[email protected]> Date: Mon Jan 4 14:21:45 2016 +0100 tdf#82775: Don't prematurely dispose single-instance services ...that happen to be requested concurrently from multiple threads Change-Id: Icecfb0b8d88c9123064689643eddf90a99d3b1b8 diff --git a/cppuhelper/source/component_context.cxx b/cppuhelper/source/component_context.cxx index 1a95f4a..21f7cfd 100644 --- a/cppuhelper/source/component_context.cxx +++ b/cppuhelper/source/component_context.cxx @@ -620,7 +620,9 @@ Any ComponentContext::lookupMap( OUString const & rName ) ret = pEntry->value; } guard.clear(); - try_dispose( xInstance ); + if (ret != xInstance) { + try_dispose( xInstance ); + } return ret; } commit 26cbb3d1049e789a1c2f56599dbfe0f379fc4b3d Author: Stephan Bergmann <[email protected]> Date: Mon Jan 4 14:20:16 2016 +0100 Related tdf#82775: Check for disposed-ness ...instead of dereferencing null pointers Change-Id: I9d1709468a5b601b9f3d86dadea7a8e817f449d8 diff --git a/framework/source/uifactory/uielementfactorymanager.cxx b/framework/source/uifactory/uielementfactorymanager.cxx index 5e4dc6d..23c68f8 100644 --- a/framework/source/uifactory/uielementfactorymanager.cxx +++ b/framework/source/uifactory/uielementfactorymanager.cxx @@ -390,33 +390,24 @@ public: private: bool m_bConfigRead; css::uno::Reference< css::uno::XComponentContext > m_xContext; - ConfigurationAccess_FactoryManager* m_pConfigAccess; + rtl::Reference<ConfigurationAccess_FactoryManager> m_pConfigAccess; }; UIElementFactoryManager::UIElementFactoryManager( const Reference< XComponentContext >& rxContext ) : UIElementFactoryManager_BASE(m_aMutex), m_bConfigRead( false ), - m_xContext(rxContext) -{ - m_pConfigAccess = new ConfigurationAccess_FactoryManager(rxContext, - "/org.openoffice.Office.UI.Factories/Registered/UIElementFactories"); - m_pConfigAccess->acquire(); -} + m_xContext(rxContext), + m_pConfigAccess( + new ConfigurationAccess_FactoryManager( + rxContext, + "/org.openoffice.Office.UI.Factories/Registered/UIElementFactories")) +{} -UIElementFactoryManager::~UIElementFactoryManager() -{ - disposing(); -} +UIElementFactoryManager::~UIElementFactoryManager() {} void SAL_CALL UIElementFactoryManager::disposing() { - osl::MutexGuard g(rBHelper.rMutex); - if (m_pConfigAccess) - { - // reduce reference count - m_pConfigAccess->release(); - m_pConfigAccess = nullptr; - } + m_pConfigAccess.clear(); } // XUIElementFactory @@ -429,6 +420,10 @@ throw ( css::container::NoSuchElementException, css::lang::IllegalArgumentExcept OUString aModuleId; { // SAFE osl::MutexGuard g(rBHelper.rMutex); + if (rBHelper.bDisposed) { + throw css::lang::DisposedException( + "disposed", static_cast<OWeakObject *>(this)); + } if ( !m_bConfigRead ) { @@ -473,6 +468,10 @@ throw ( RuntimeException, std::exception ) { // SAFE osl::MutexGuard g(rBHelper.rMutex); + if (rBHelper.bDisposed) { + throw css::lang::DisposedException( + "disposed", static_cast<OWeakObject *>(this)); + } if ( !m_bConfigRead ) { @@ -489,6 +488,10 @@ throw ( RuntimeException, std::exception ) OUString aServiceSpecifier; { // SAFE osl::MutexGuard g(rBHelper.rMutex); + if (rBHelper.bDisposed) { + throw css::lang::DisposedException( + "disposed", static_cast<OWeakObject *>(this)); + } if ( !m_bConfigRead ) { @@ -524,6 +527,10 @@ throw ( ElementExistException, RuntimeException, std::exception ) { // SAFE osl::MutexGuard g(rBHelper.rMutex); + if (rBHelper.bDisposed) { + throw css::lang::DisposedException( + "disposed", static_cast<OWeakObject *>(this)); + } if ( !m_bConfigRead ) { @@ -540,6 +547,10 @@ throw ( NoSuchElementException, RuntimeException, std::exception ) { // SAFE osl::MutexGuard g(rBHelper.rMutex); + if (rBHelper.bDisposed) { + throw css::lang::DisposedException( + "disposed", static_cast<OWeakObject *>(this)); + } if ( !m_bConfigRead ) { diff --git a/framework/source/uifactory/windowcontentfactorymanager.cxx b/framework/source/uifactory/windowcontentfactorymanager.cxx index d9a1c7a..de66679 100644 --- a/framework/source/uifactory/windowcontentfactorymanager.cxx +++ b/framework/source/uifactory/windowcontentfactorymanager.cxx @@ -33,6 +33,7 @@ #include <cppuhelper/basemutex.hxx> #include <cppuhelper/compbase.hxx> #include <cppuhelper/supportsservice.hxx> +#include <rtl/ref.hxx> #include <tools/diagnose_ex.h> using namespace ::com::sun::star; @@ -79,34 +80,24 @@ private: css::uno::Reference< css::uno::XComponentContext > m_xContext; bool m_bConfigRead; - ConfigurationAccess_FactoryManager* m_pConfigAccess; + rtl::Reference<ConfigurationAccess_FactoryManager> m_pConfigAccess; }; WindowContentFactoryManager::WindowContentFactoryManager( const uno::Reference< uno::XComponentContext >& rxContext ) : WindowContentFactoryManager_BASE(m_aMutex), m_xContext( rxContext ), - m_bConfigRead( false ) -{ - m_pConfigAccess = new ConfigurationAccess_FactoryManager( m_xContext, - "/org.openoffice.Office.UI.WindowContentFactories/Registered/ContentFactories" ); - m_pConfigAccess->acquire(); -} + m_bConfigRead( false ), + m_pConfigAccess( + new ConfigurationAccess_FactoryManager( + m_xContext, + "/org.openoffice.Office.UI.WindowContentFactories/Registered/ContentFactories")) +{} -WindowContentFactoryManager::~WindowContentFactoryManager() -{ - disposing(); -} +WindowContentFactoryManager::~WindowContentFactoryManager() {} void SAL_CALL WindowContentFactoryManager::disposing() { - osl::MutexGuard g(rBHelper.rMutex); - - if (m_pConfigAccess) - { - // reduce reference count - m_pConfigAccess->release(); - m_pConfigAccess = nullptr; - } + m_pConfigAccess.clear(); } // XSingleComponentFactory @@ -165,6 +156,10 @@ throw (uno::Exception, uno::RuntimeException, std::exception) // module identifier, user interface element type and name { // SAFE osl::MutexGuard g(rBHelper.rMutex); + if (rBHelper.bDisposed) { + throw css::lang::DisposedException( + "disposed", static_cast<OWeakObject *>(this)); + } if ( !m_bConfigRead ) { m_bConfigRead = true; _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
