diff options
-rw-r--r-- | chart2/source/controller/inc/ChartController.hxx | 6 | ||||
-rw-r--r-- | chart2/source/controller/main/ChartController.cxx | 30 |
2 files changed, 9 insertions, 27 deletions
diff --git a/chart2/source/controller/inc/ChartController.hxx b/chart2/source/controller/inc/ChartController.hxx index 3b3449170eec..eb2ba8857696 100644 --- a/chart2/source/controller/inc/ChartController.hxx +++ b/chart2/source/controller/inc/ChartController.hxx @@ -414,10 +414,10 @@ private: TheModelRef& operator=(const TheModelRef& rTheModel); ~TheModelRef(); bool is() const; - TheModel* operator->() const { return m_pTheModel; } + TheModel* operator->() const { return m_xTheModel.get(); } private: - TheModel* m_pTheModel; - ::osl::Mutex& m_rModelMutex; + rtl::Reference<TheModel> m_xTheModel; + ::osl::Mutex& m_rModelMutex; }; private: diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx index 0233edbbd7b2..8c331a2fe484 100644 --- a/chart2/source/controller/main/ChartController.cxx +++ b/chart2/source/controller/main/ChartController.cxx @@ -221,55 +221,37 @@ void ChartController::TheModel::tryTermination() } ChartController::TheModelRef::TheModelRef( TheModel* pTheModel, osl::Mutex& rMutex ) : - m_pTheModel(pTheModel), m_rModelMutex(rMutex) { osl::Guard< osl::Mutex > aGuard( m_rModelMutex ); - if(m_pTheModel) - m_pTheModel->acquire(); + m_xTheModel = pTheModel; } ChartController::TheModelRef::TheModelRef( const TheModelRef& rTheModel, ::osl::Mutex& rMutex ) : m_rModelMutex(rMutex) { osl::Guard< osl::Mutex > aGuard( m_rModelMutex ); - m_pTheModel=rTheModel.operator->(); - if(m_pTheModel) - m_pTheModel->acquire(); + m_xTheModel = rTheModel.m_xTheModel; } ChartController::TheModelRef& ChartController::TheModelRef::operator=(TheModel* pTheModel) { osl::Guard< osl::Mutex > aGuard( m_rModelMutex ); - if(m_pTheModel==pTheModel) - return *this; - if(m_pTheModel) - m_pTheModel->release(); - m_pTheModel=pTheModel; - if(m_pTheModel) - m_pTheModel->acquire(); + m_xTheModel = pTheModel; return *this; } ChartController::TheModelRef& ChartController::TheModelRef::operator=(const TheModelRef& rTheModel) { osl::Guard< osl::Mutex > aGuard( m_rModelMutex ); - TheModel* pNew=rTheModel.operator->(); - if(m_pTheModel==pNew) - return *this; - if(m_pTheModel) - m_pTheModel->release(); - m_pTheModel=pNew; - if(m_pTheModel) - m_pTheModel->acquire(); + m_xTheModel = rTheModel.operator->(); return *this; } ChartController::TheModelRef::~TheModelRef() { osl::Guard< osl::Mutex > aGuard( m_rModelMutex ); - if(m_pTheModel) - m_pTheModel->release(); + m_xTheModel.clear(); } bool ChartController::TheModelRef::is() const { - return (m_pTheModel != nullptr); + return m_xTheModel.is(); } namespace { |