summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2016-01-04 14:20:16 +0100
committerStephan Bergmann <sbergman@redhat.com>2016-01-04 14:20:16 +0100
commit26cbb3d1049e789a1c2f56599dbfe0f379fc4b3d (patch)
tree506aa7df28a44b31b748780513f70938d3ffa971 /framework
parent38e965fe0fcabffadb8fabe6756313b4f37daad5 (diff)
Related tdf#82775: Check for disposed-ness
...instead of dereferencing null pointers Change-Id: I9d1709468a5b601b9f3d86dadea7a8e817f449d8
Diffstat (limited to 'framework')
-rw-r--r--framework/source/uifactory/uielementfactorymanager.cxx47
-rw-r--r--framework/source/uifactory/windowcontentfactorymanager.cxx33
2 files changed, 43 insertions, 37 deletions
diff --git a/framework/source/uifactory/uielementfactorymanager.cxx b/framework/source/uifactory/uielementfactorymanager.cxx
index 5e4dc6d22b55..23c68f8c7745 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 d9a1c7a6b322..de66679c854a 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;