diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-01-19 13:19:13 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-01-20 08:51:08 +0200 |
commit | 46a0ce80326a44bd13e3483106dd0e9bf32a7824 (patch) | |
tree | dd6858fbef8359bbaf7b91e52e4fc1b7b77e96be /chart2/source/controller/main | |
parent | cef8ebe925bde6fc1889085e3ccb1be236791e99 (diff) |
use rtl::Reference in TheModelRef
instead of manual acquire/release
Change-Id: I7a5ae0337fc8fa1465ac716050e7187aa1accb87
Diffstat (limited to 'chart2/source/controller/main')
-rw-r--r-- | chart2/source/controller/main/ChartController.cxx | 30 |
1 files changed, 6 insertions, 24 deletions
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 { |