[Libreoffice-commits] core.git: 4 commits - chart2/source comphelper/source extensions/source include/comphelper
Noel Grandin
noel.grandin at collabora.co.uk
Fri Jan 20 06:51:44 UTC 2017
chart2/source/controller/inc/ChartController.hxx | 6 +--
chart2/source/controller/main/ChartController.cxx | 30 +++------------
comphelper/source/container/containermultiplexer.cxx | 23 ++---------
extensions/source/bibliography/bibload.cxx | 31 +++++++---------
extensions/source/bibliography/formcontrolcontainer.cxx | 11 ++---
extensions/source/bibliography/formcontrolcontainer.hxx | 5 +-
include/comphelper/containermultiplexer.hxx | 5 +-
7 files changed, 38 insertions(+), 73 deletions(-)
New commits:
commit 3bb8bdb93f1546f64ff3f183d6162c41a03856bf
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Thu Jan 19 16:02:25 2017 +0200
use rtl::Reference in OContainerListener
instead of manual acquire/release
Change-Id: I83e6229029e662073e2e01e98f4846fb0a0ed643
diff --git a/comphelper/source/container/containermultiplexer.cxx b/comphelper/source/container/containermultiplexer.cxx
index b7e3c93..e80f550 100644
--- a/comphelper/source/container/containermultiplexer.cxx
+++ b/comphelper/source/container/containermultiplexer.cxx
@@ -29,18 +29,16 @@ namespace comphelper
using namespace ::com::sun::star::container;
OContainerListener::OContainerListener(::osl::Mutex& _rMutex)
- :m_pAdapter(nullptr)
- ,m_rMutex(_rMutex)
+ :m_rMutex(_rMutex)
{
}
OContainerListener::~OContainerListener()
{
- if (m_pAdapter)
+ if (m_xAdapter.is())
{
- m_pAdapter->dispose();
- m_pAdapter = nullptr;
+ m_xAdapter->dispose();
}
}
@@ -71,19 +69,8 @@ namespace comphelper
void OContainerListener::setAdapter(OContainerListenerAdapter* pAdapter)
{
- if (m_pAdapter)
- {
- ::osl::MutexGuard aGuard(m_rMutex);
- m_pAdapter->release();
- m_pAdapter = nullptr;
- }
-
- if (pAdapter)
- {
- ::osl::MutexGuard aGuard(m_rMutex);
- m_pAdapter = pAdapter;
- m_pAdapter->acquire();
- }
+ ::osl::MutexGuard aGuard(m_rMutex);
+ m_xAdapter = pAdapter;
}
OContainerListenerAdapter::OContainerListenerAdapter(OContainerListener* _pListener,
diff --git a/include/comphelper/containermultiplexer.hxx b/include/comphelper/containermultiplexer.hxx
index 946ff69..07b0443 100644
--- a/include/comphelper/containermultiplexer.hxx
+++ b/include/comphelper/containermultiplexer.hxx
@@ -24,6 +24,7 @@
#include <cppuhelper/implbase.hxx>
#include <osl/mutex.hxx>
#include <comphelper/comphelperdllapi.h>
+#include <rtl/ref.hxx>
namespace comphelper
@@ -43,8 +44,8 @@ namespace comphelper
{
friend class OContainerListenerAdapter;
protected:
- OContainerListenerAdapter* m_pAdapter;
- ::osl::Mutex& m_rMutex;
+ rtl::Reference<OContainerListenerAdapter> m_xAdapter;
+ ::osl::Mutex& m_rMutex;
public:
OContainerListener(::osl::Mutex& _rMutex);
commit 3663edf465e87d823e354b320b8d072f7764d5dc
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Thu Jan 19 14:03:19 2017 +0200
use rtl::Reference in BibliographyLoader
instead of storing both a raw pointer and an uno::Reference
Change-Id: Ic46c5cda34c1df818cbe1ffa4b2d44d1519b4d6f
diff --git a/extensions/source/bibliography/bibload.cxx b/extensions/source/bibliography/bibload.cxx
index 2ffbb76..af9a478 100644
--- a/extensions/source/bibliography/bibload.cxx
+++ b/extensions/source/bibliography/bibload.cxx
@@ -61,6 +61,7 @@
#include "datman.hxx"
#include <bibconfig.hxx>
#include <cppuhelper/implbase.hxx>
+#include <rtl/ref.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -76,8 +77,7 @@ class BibliographyLoader : public cppu::WeakImplHelper
< XServiceInfo, XNameAccess, XPropertySet, XFrameLoader >
{
HdlBibModul m_pBibMod;
- Reference< XLoadable > m_xDatMan;
- BibDataManager* m_pDatMan;
+ rtl::Reference<BibDataManager> m_xDatMan;
Reference< XNameAccess > m_xColumns;
Reference< XResultSet > m_xCursor;
@@ -139,8 +139,7 @@ public:
};
BibliographyLoader::BibliographyLoader() :
- m_pBibMod(nullptr),
- m_pDatMan(nullptr)
+ m_pBibMod(nullptr)
{
}
@@ -253,8 +252,7 @@ void BibliographyLoader::loadView(const Reference< XFrame > & rFrame, const OUSt
if(!m_pBibMod)
m_pBibMod = OpenBibModul();
- m_pDatMan = BibModul::createDataManager();
- m_xDatMan = m_pDatMan;
+ m_xDatMan = BibModul::createDataManager();
BibDBDescriptor aBibDesc = BibModul::GetConfig()->GetBibliographyURL();
if(aBibDesc.sDataSource.isEmpty())
@@ -265,7 +263,7 @@ void BibliographyLoader::loadView(const Reference< XFrame > & rFrame, const OUSt
aBibDesc.sDataSource = aSources.getConstArray()[0];
}
- Reference< XForm > xForm = m_pDatMan->createDatabaseForm( aBibDesc );
+ Reference< XForm > xForm = m_xDatMan->createDatabaseForm( aBibDesc );
Reference< awt::XWindow > aWindow = rFrame->getContainerWindow();
VCLXWindow* pParentComponent = VCLXWindow::GetImplementation(aWindow);
@@ -276,11 +274,11 @@ void BibliographyLoader::loadView(const Reference< XFrame > & rFrame, const OUSt
VclPtrInstance<BibBookContainer> pMyWindow( pParent );
pMyWindow->Show();
- VclPtrInstance< ::bib::BibView> pView( pMyWindow, m_pDatMan, WB_VSCROLL | WB_HSCROLL | WB_3DLOOK );
+ VclPtrInstance< ::bib::BibView> pView( pMyWindow, m_xDatMan.get(), WB_VSCROLL | WB_HSCROLL | WB_3DLOOK );
pView->Show();
- m_pDatMan->SetView( pView );
+ m_xDatMan->SetView( pView );
- VclPtrInstance< ::bib::BibBeamer> pBeamer( pMyWindow, m_pDatMan );
+ VclPtrInstance< ::bib::BibBeamer> pBeamer( pMyWindow, m_xDatMan.get() );
pBeamer->Show();
pMyWindow->createTopFrame(pBeamer);
@@ -288,7 +286,7 @@ void BibliographyLoader::loadView(const Reference< XFrame > & rFrame, const OUSt
Reference< awt::XWindow > xWin ( pMyWindow->GetComponentInterface(), UNO_QUERY );
- Reference< XController > xCtrRef( new BibFrameController_Impl( xWin, m_pDatMan ) );
+ Reference< XController > xCtrRef( new BibFrameController_Impl( xWin, m_xDatMan.get() ) );
xCtrRef->attachFrame(rFrame);
rFrame->setComponent( xWin, xCtrRef);
@@ -300,8 +298,8 @@ void BibliographyLoader::loadView(const Reference< XFrame > & rFrame, const OUSt
pParentComponent->setVisible(true);
}
- m_xDatMan->load();
- m_pDatMan->RegisterInterceptor(pBeamer);
+ Reference<XLoadable>(m_xDatMan.get())->load();
+ m_xDatMan->RegisterInterceptor(pBeamer);
if ( rListener.is() )
rListener->loadFinished( this );
@@ -327,14 +325,13 @@ void BibliographyLoader::loadView(const Reference< XFrame > & rFrame, const OUSt
BibDataManager* BibliographyLoader::GetDataManager()const
{
- if(!m_pDatMan)
+ if(!m_xDatMan.is())
{
if(!m_pBibMod)
const_cast< BibliographyLoader* >( this )->m_pBibMod = OpenBibModul();
- const_cast< BibliographyLoader* >( this )->m_pDatMan = BibModul::createDataManager();
- const_cast< BibliographyLoader* >( this )->m_xDatMan = m_pDatMan;
+ const_cast< BibliographyLoader* >( this )->m_xDatMan = BibModul::createDataManager();
}
- return m_pDatMan;
+ return m_xDatMan.get();
}
Reference< XNameAccess > const & BibliographyLoader::GetDataColumns() const
commit 7d7a5666aea903ad69276a4d65b0df2768d473b8
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Thu Jan 19 13:58:56 2017 +0200
use rtl::Reference in FormControlContainer
instead of manual acquire/release
Change-Id: Ie0fed7db217adea68aaa09cf9de699d488bf84dd
diff --git a/extensions/source/bibliography/formcontrolcontainer.cxx b/extensions/source/bibliography/formcontrolcontainer.cxx
index f0dfe3b..4da38e3 100644
--- a/extensions/source/bibliography/formcontrolcontainer.cxx
+++ b/extensions/source/bibliography/formcontrolcontainer.cxx
@@ -35,7 +35,6 @@ namespace bib
FormControlContainer::FormControlContainer( )
:OLoadListener( m_aMutex )
- ,m_pFormAdapter( nullptr )
{
}
@@ -52,9 +51,8 @@ namespace bib
SAL_WARN_IF( !isFormConnected(), "extensions.biblio", "FormControlContainer::connectForm: not connected!" );
if ( isFormConnected() )
{
- m_pFormAdapter->dispose();
- m_pFormAdapter->release();
- m_pFormAdapter = nullptr;
+ m_xFormAdapter->dispose();
+ m_xFormAdapter.clear();
}
}
@@ -65,9 +63,8 @@ namespace bib
SAL_WARN_IF( !_rxForm.is(), "extensions.biblio", "FormControlContainer::connectForm: invalid form!" );
if ( !isFormConnected() && _rxForm.is() )
{
- m_pFormAdapter = new OLoadListenerAdapter( _rxForm );
- m_pFormAdapter->acquire();
- m_pFormAdapter->Init( this );
+ m_xFormAdapter = new OLoadListenerAdapter( _rxForm );
+ m_xFormAdapter->Init( this );
implSetDesignMode( !m_xForm.is() || !m_xForm->isLoaded() );
}
diff --git a/extensions/source/bibliography/formcontrolcontainer.hxx b/extensions/source/bibliography/formcontrolcontainer.hxx
index a75a528..78673eb 100644
--- a/extensions/source/bibliography/formcontrolcontainer.hxx
+++ b/extensions/source/bibliography/formcontrolcontainer.hxx
@@ -23,6 +23,7 @@
#include <cppuhelper/basemutex.hxx>
#include "loadlisteneradapter.hxx"
#include <com/sun/star/awt/XControlContainer.hpp>
+#include <rtl/ref.hxx>
namespace bib
@@ -33,7 +34,7 @@ namespace bib
,public ::bib::OLoadListener
{
private:
- OLoadListenerAdapter* m_pFormAdapter;
+ rtl::Reference<OLoadListenerAdapter> m_xFormAdapter;
css::uno::Reference< css::form::XLoadable > m_xForm;
private:
void implSetDesignMode( bool _bDesign );
@@ -42,7 +43,7 @@ namespace bib
FormControlContainer( );
virtual ~FormControlContainer( ) override;
- bool isFormConnected() const { return nullptr != m_pFormAdapter; }
+ bool isFormConnected() const { return m_xFormAdapter.is(); }
void connectForm( const css::uno::Reference< css::form::XLoadable >& _rxForm );
void disconnectForm();
commit 46a0ce80326a44bd13e3483106dd0e9bf32a7824
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Thu Jan 19 13:19:13 2017 +0200
use rtl::Reference in TheModelRef
instead of manual acquire/release
Change-Id: I7a5ae0337fc8fa1465ac716050e7187aa1accb87
diff --git a/chart2/source/controller/inc/ChartController.hxx b/chart2/source/controller/inc/ChartController.hxx
index 3b34491..eb2ba88 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 0233edb..8c331a2 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 {
More information about the Libreoffice-commits
mailing list