summaryrefslogtreecommitdiff
path: root/forms
diff options
context:
space:
mode:
authorNoel <noel.grandin@collabora.co.uk>2021-02-21 13:33:00 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-02-21 16:10:51 +0100
commit7ffb71e759e5d29a505188d1cbf506dd57383a4a (patch)
treee1828c9b7a800cc51b4b16898b0303fc1789211b /forms
parent6dccc6b54e4bb13f765d494bcdcdd782fa11fe38 (diff)
loplugin:refcounting in forms
Change-Id: I19d67e54f77e354eaddaaa7de1f3e22c2b7cdbf6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111280 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'forms')
-rw-r--r--forms/source/component/DatabaseForm.cxx4
-rw-r--r--forms/source/component/FormComponent.cxx4
-rw-r--r--forms/source/component/FormattedField.cxx9
-rw-r--r--forms/source/component/FormattedField.hxx1
-rw-r--r--forms/source/component/FormattedFieldWrapper.cxx19
-rw-r--r--forms/source/component/FormsCollection.cxx7
-rw-r--r--forms/source/component/Grid.cxx6
-rw-r--r--forms/source/component/clickableimage.cxx2
-rw-r--r--forms/source/component/navigationbar.hxx1
-rw-r--r--forms/source/inc/FormComponent.hxx4
-rw-r--r--forms/source/richtext/richtextcontrol.cxx6
-rw-r--r--forms/source/richtext/richtextmodel.cxx2
-rw-r--r--forms/source/richtext/richtextmodel.hxx2
-rw-r--r--forms/source/xforms/binding.cxx5
-rw-r--r--forms/source/xforms/model_ui.cxx6
-rw-r--r--forms/source/xforms/submission.cxx15
-rw-r--r--forms/source/xforms/submission/replace.cxx5
-rw-r--r--forms/source/xforms/submission/submission_get.cxx4
18 files changed, 41 insertions, 61 deletions
diff --git a/forms/source/component/DatabaseForm.cxx b/forms/source/component/DatabaseForm.cxx
index 066eeb45e293..7411abf90351 100644
--- a/forms/source/component/DatabaseForm.cxx
+++ b/forms/source/component/DatabaseForm.cxx
@@ -1373,10 +1373,8 @@ void SAL_CALL ODatabaseForm::clearWarnings( )
Reference< XCloneable > SAL_CALL ODatabaseForm::createClone( )
{
- ODatabaseForm* pClone = new ODatabaseForm( *this );
- osl_atomic_increment( &pClone->m_refCount );
+ rtl::Reference<ODatabaseForm> pClone = new ODatabaseForm( *this );
pClone->clonedFrom( *this );
- osl_atomic_decrement( &pClone->m_refCount );
return pClone;
}
diff --git a/forms/source/component/FormComponent.cxx b/forms/source/component/FormComponent.cxx
index 8b3047cc176b..e2a6a582ed31 100644
--- a/forms/source/component/FormComponent.cxx
+++ b/forms/source/component/FormComponent.cxx
@@ -1137,7 +1137,6 @@ OBoundControlModel::OBoundControlModel(
,m_aUpdateListeners(m_aMutex)
,m_aFormComponentListeners( m_aMutex )
,m_bInputRequired( false )
- ,m_pAggPropMultiplexer( nullptr )
,m_bFormListening( false )
,m_bLoaded(false)
,m_bRequired(false)
@@ -1170,7 +1169,6 @@ OBoundControlModel::OBoundControlModel(
,m_aFormComponentListeners( m_aMutex )
,m_xValidator( _pOriginal->m_xValidator )
,m_bInputRequired( false )
- ,m_pAggPropMultiplexer( nullptr )
,m_bFormListening( false )
,m_bLoaded( false )
,m_bRequired( false )
@@ -1214,7 +1212,6 @@ OBoundControlModel::~OBoundControlModel()
if ( m_pAggPropMultiplexer )
{
m_pAggPropMultiplexer->dispose();
- m_pAggPropMultiplexer->release();
m_pAggPropMultiplexer = nullptr;
}
}
@@ -1244,7 +1241,6 @@ void OBoundControlModel::implInitAggMultiplexer( )
if ( m_xAggregateSet.is() )
{
m_pAggPropMultiplexer = new OPropertyChangeMultiplexer( this, m_xAggregateSet, false );
- m_pAggPropMultiplexer->acquire();
}
osl_atomic_decrement( &m_refCount );
diff --git a/forms/source/component/FormattedField.cxx b/forms/source/component/FormattedField.cxx
index ed2f748fb7cd..74e6aaf08e01 100644
--- a/forms/source/component/FormattedField.cxx
+++ b/forms/source/component/FormattedField.cxx
@@ -72,7 +72,7 @@ namespace frm
{
namespace {
-class StandardFormatsSupplier : protected SvNumberFormatsSupplierObj, public ::utl::ITerminationListener
+class StandardFormatsSupplier : public SvNumberFormatsSupplierObj, public ::utl::ITerminationListener
{
protected:
std::unique_ptr<SvNumberFormatter> m_pMyPrivateFormatter;
@@ -113,8 +113,7 @@ Reference< XNumberFormatsSupplier > StandardFormatsSupplier::get( const Referenc
// get the Office's locale
eSysLanguage = SvtSysLocale().GetLanguageTag().getLanguageType( false);
}
- StandardFormatsSupplier* pSupplier = new StandardFormatsSupplier( _rxORB, eSysLanguage );
- Reference< XNumberFormatsSupplier > xNewlyCreatedSupplier( pSupplier );
+ rtl::Reference<StandardFormatsSupplier> pSupplier = new StandardFormatsSupplier( _rxORB, eSysLanguage );
{
::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
Reference< XNumberFormatsSupplier > xSupplier = s_xDefaultFormatsSupplier;
@@ -122,9 +121,9 @@ Reference< XNumberFormatsSupplier > StandardFormatsSupplier::get( const Referenc
// somebody used the small time frame where the mutex was not locked to create and set
// the supplier
return xSupplier;
- s_xDefaultFormatsSupplier = xNewlyCreatedSupplier;
+ s_xDefaultFormatsSupplier = pSupplier;
}
- return xNewlyCreatedSupplier;
+ return pSupplier;
}
bool StandardFormatsSupplier::queryTermination() const
{
diff --git a/forms/source/component/FormattedField.hxx b/forms/source/component/FormattedField.hxx
index 78b0367d92b0..1d35060e0588 100644
--- a/forms/source/component/FormattedField.hxx
+++ b/forms/source/component/FormattedField.hxx
@@ -55,6 +55,7 @@ class OFormattedModel final
friend class OFormattedFieldWrapper;
+ public:
// XInterface
DECLARE_UNO3_AGG_DEFAULTS( OFormattedModel, OEditBaseModel )
diff --git a/forms/source/component/FormattedFieldWrapper.cxx b/forms/source/component/FormattedFieldWrapper.cxx
index d169ff4eaade..8a8f27830395 100644
--- a/forms/source/component/FormattedFieldWrapper.cxx
+++ b/forms/source/component/FormattedFieldWrapper.cxx
@@ -51,34 +51,29 @@ OFormattedFieldWrapper::OFormattedFieldWrapper(const Reference<XComponentContext
css::uno::Reference<css::uno::XInterface> OFormattedFieldWrapper::createFormattedFieldWrapper(const css::uno::Reference< css::uno::XComponentContext>& _rxFactory, bool bActAsFormatted)
{
- OFormattedFieldWrapper *pRef = new OFormattedFieldWrapper(_rxFactory);
+ rtl::Reference<OFormattedFieldWrapper> pRef = new OFormattedFieldWrapper(_rxFactory);
if (bActAsFormatted)
{
// instantiate a FormattedModel
// (instantiate it directly ..., as the OFormattedModel isn't
// registered for any service names anymore)
- OFormattedModel* pModel = new OFormattedModel(pRef->m_xContext);
- css::uno::Reference<css::uno::XInterface> xFormattedModel(
- static_cast<XWeak*>(pModel), css::uno::UNO_QUERY);
+ rtl::Reference<OFormattedModel> pModel = new OFormattedModel(pRef->m_xContext);
- pRef->m_xAggregate.set(xFormattedModel, UNO_QUERY);
+ pRef->m_xAggregate = pModel;
OSL_ENSURE(pRef->m_xAggregate.is(), "the OFormattedModel didn't have an XAggregation interface !");
// _before_ setting the delegator, give it to the member references
- pRef->m_xFormattedPart.set(xFormattedModel, css::uno::UNO_QUERY);
+ pRef->m_xFormattedPart = pModel;
pRef->m_pEditPart.set(new OEditModel(pRef->m_xContext));
}
- osl_atomic_increment(&pRef->m_refCount);
-
if (pRef->m_xAggregate.is())
{ // has to be in its own block because of the temporary variable created by *this
- pRef->m_xAggregate->setDelegator(static_cast<XWeak*>(pRef));
+ pRef->m_xAggregate->setDelegator(static_cast<XWeak*>(pRef.get()));
}
css::uno::Reference<css::uno::XInterface> xRef(*pRef);
- osl_atomic_decrement(&pRef->m_refCount);
return xRef;
}
@@ -317,8 +312,8 @@ void OFormattedFieldWrapper::ensureAggregate()
if (!xEditModel.is())
{
// arghhh... instantiate it directly... it's dirty, but we really need this aggregate
- OEditModel* pModel = new OEditModel(m_xContext);
- xEditModel.set(static_cast<XWeak*>(pModel), css::uno::UNO_QUERY);
+ rtl::Reference<OEditModel> pModel = new OEditModel(m_xContext);
+ xEditModel.set(static_cast<XWeak*>(pModel.get()), css::uno::UNO_QUERY);
}
m_xAggregate.set(xEditModel, UNO_QUERY);
diff --git a/forms/source/component/FormsCollection.cxx b/forms/source/component/FormsCollection.cxx
index e213b31e49d2..0f1b6d95c056 100644
--- a/forms/source/component/FormsCollection.cxx
+++ b/forms/source/component/FormsCollection.cxx
@@ -22,6 +22,7 @@
#include <cppuhelper/supportsservice.hxx>
#include <sal/log.hxx>
#include <com/sun/star/form/XForm.hpp>
+#include <rtl/ref.hxx>
using namespace frm;
using namespace ::com::sun::star::lang;
@@ -100,11 +101,9 @@ css::uno::Sequence<OUString> SAL_CALL OFormsCollection::getSupportedServiceNames
// XCloneable
Reference< XCloneable > SAL_CALL OFormsCollection::createClone( )
{
- OFormsCollection* pClone = new OFormsCollection( *this );
- osl_atomic_increment( &pClone->m_refCount );
+ rtl::Reference<OFormsCollection> pClone = new OFormsCollection( *this );
pClone->clonedFrom( *this );
- osl_atomic_decrement( &pClone->m_refCount );
- return static_cast<OInterfaceContainer*>(pClone);
+ return static_cast<OInterfaceContainer*>(pClone.get());
}
// OComponentHelper
diff --git a/forms/source/component/Grid.cxx b/forms/source/component/Grid.cxx
index 0677420f0bea..041fd89c77d0 100644
--- a/forms/source/component/Grid.cxx
+++ b/forms/source/component/Grid.cxx
@@ -119,14 +119,12 @@ OGridControlModel::~OGridControlModel()
// XCloneable
Reference< XCloneable > SAL_CALL OGridControlModel::createClone( )
{
- OGridControlModel* pClone = new OGridControlModel( this, getContext() );
- osl_atomic_increment( &pClone->m_refCount );
+ rtl::Reference<OGridControlModel> pClone = new OGridControlModel( this, getContext() );
pClone->OControlModel::clonedFrom( this );
// do not call OInterfaceContainer::clonedFrom, it would clone the elements aka columns, which is
// already done in the ctor
//pClone->OInterfaceContainer::clonedFrom( *this );
- osl_atomic_decrement( &pClone->m_refCount );
- return static_cast< XCloneable* >( static_cast< OControlModel* >( pClone ) );
+ return static_cast< XCloneable* >( static_cast< OControlModel* >( pClone.get() ) );
}
void OGridControlModel::cloneColumns( const OGridControlModel* _pOriginalContainer )
diff --git a/forms/source/component/clickableimage.cxx b/forms/source/component/clickableimage.cxx
index f46bbb562545..d04ffdf49ffd 100644
--- a/forms/source/component/clickableimage.cxx
+++ b/forms/source/component/clickableimage.cxx
@@ -495,7 +495,7 @@ namespace frm
{
if ( m_xAggregateSet.is() )
{
- OPropertyChangeMultiplexer* pMultiplexer = new OPropertyChangeMultiplexer( this, m_xAggregateSet );
+ rtl::Reference<OPropertyChangeMultiplexer> pMultiplexer = new OPropertyChangeMultiplexer( this, m_xAggregateSet );
pMultiplexer->addProperty( PROPERTY_IMAGE_URL );
}
}
diff --git a/forms/source/component/navigationbar.hxx b/forms/source/component/navigationbar.hxx
index f393a046f542..af55f64e4b1f 100644
--- a/forms/source/component/navigationbar.hxx
+++ b/forms/source/component/navigationbar.hxx
@@ -62,7 +62,6 @@ namespace frm
public:
DECLARE_DEFAULT_LEAF_XTOR( ONavigationBarModel );
- protected:
// UNO
DECLARE_UNO3_AGG_DEFAULTS( ONavigationBarModel, OControlModel )
virtual css::uno::Any SAL_CALL queryAggregation( const css::uno::Type& _rType ) override;
diff --git a/forms/source/inc/FormComponent.hxx b/forms/source/inc/FormComponent.hxx
index 4a2fc4bf95ca..5ac06a927660 100644
--- a/forms/source/inc/FormComponent.hxx
+++ b/forms/source/inc/FormComponent.hxx
@@ -512,7 +512,7 @@ public:
#define IMPLEMENT_DEFAULT_CLONING( classname ) \
css::uno::Reference< css::util::XCloneable > SAL_CALL classname::createClone( ) \
{ \
- classname* pClone = new classname( this, getContext() ); \
+ rtl::Reference<classname> pClone = new classname( this, getContext() ); \
pClone->clonedFrom( this ); \
return pClone; \
}
@@ -587,7 +587,7 @@ private:
bool m_bInputRequired;
// </properties>
- ::comphelper::OPropertyChangeMultiplexer*
+ rtl::Reference<::comphelper::OPropertyChangeMultiplexer>
m_pAggPropMultiplexer;
bool m_bFormListening : 1; // are we currently a XLoadListener at our ambient form?
diff --git a/forms/source/richtext/richtextcontrol.cxx b/forms/source/richtext/richtextcontrol.cxx
index ad857d328685..45e898b8ed13 100644
--- a/forms/source/richtext/richtextcontrol.cxx
+++ b/forms/source/richtext/richtextcontrol.cxx
@@ -442,8 +442,8 @@ namespace frm
if ( !pRichTextControl )
return SingleAttributeDispatcher( nullptr );
- ORichTextFeatureDispatcher* pDispatcher = nullptr;
- OAttributeDispatcher* pAttributeDispatcher = nullptr;
+ rtl::Reference<ORichTextFeatureDispatcher> pDispatcher;
+ rtl::Reference<OAttributeDispatcher> pAttributeDispatcher;
switch ( _nSlotId )
{
case SID_CUT:
@@ -547,7 +547,7 @@ namespace frm
if ( pAttributeDispatcher )
{
xDispatcher = SingleAttributeDispatcher( pAttributeDispatcher );
- pRichTextControl->enableAttributeNotification( _nSlotId, pAttributeDispatcher );
+ pRichTextControl->enableAttributeNotification( _nSlotId, pAttributeDispatcher.get() );
}
return xDispatcher;
diff --git a/forms/source/richtext/richtextmodel.cxx b/forms/source/richtext/richtextmodel.cxx
index ece2d36e96fe..9e33fb2118dd 100644
--- a/forms/source/richtext/richtextmodel.cxx
+++ b/forms/source/richtext/richtextmodel.cxx
@@ -136,7 +136,7 @@ namespace frm
nEngineControlWord = nEngineControlWord & ~EEControlBits::AUTOPAGESIZE;
m_pEngine->SetControlWord( nEngineControlWord );
- VCLXDevice* pUnoRefDevice = new VCLXDevice;
+ rtl::Reference<VCLXDevice> pUnoRefDevice = new VCLXDevice;
{
SolarMutexGuard g;
pUnoRefDevice->SetOutputDevice( m_pEngine->GetRefDevice() );
diff --git a/forms/source/richtext/richtextmodel.hxx b/forms/source/richtext/richtextmodel.hxx
index 493fbda75807..ef3aff536fb9 100644
--- a/forms/source/richtext/richtextmodel.hxx
+++ b/forms/source/richtext/richtextmodel.hxx
@@ -101,8 +101,6 @@ namespace frm
public:
static RichTextEngine* getEditEngine( const css::uno::Reference< css::awt::XControlModel >& _rxModel );
- private:
-
// UNO
DECLARE_UNO3_AGG_DEFAULTS( ORichTextModel, OControlModel )
virtual css::uno::Any SAL_CALL queryAggregation( const css::uno::Type& _rType ) override;
diff --git a/forms/source/xforms/binding.cxx b/forms/source/xforms/binding.cxx
index a3a60864d62a..06a21384d8d6 100644
--- a/forms/source/xforms/binding.cxx
+++ b/forms/source/xforms/binding.cxx
@@ -673,9 +673,8 @@ void Binding::valueModified()
void Binding::distributeMIP( const css::uno::Reference<css::xml::dom::XNode> & rxNode ) {
- css::xforms::XFormsEventConcrete *pEvent = new css::xforms::XFormsEventConcrete;
+ rtl::Reference<css::xforms::XFormsEventConcrete> pEvent = new css::xforms::XFormsEventConcrete;
pEvent->initXFormsEvent("xforms-generic", true, false);
- Reference<XEvent> xEvent(pEvent);
// naive depth-first traversal
css::uno::Reference<css::xml::dom::XNode> xNode( rxNode );
@@ -692,7 +691,7 @@ void Binding::distributeMIP( const css::uno::Reference<css::xml::dom::XNode> & r
// bindings which are listening at this node will receive
// a notification message about what exactly happened.
Reference< XEventTarget > target(xNode,UNO_QUERY);
- target->dispatchEvent(xEvent);
+ target->dispatchEvent(pEvent);
xNode = xNode->getNextSibling();
}
diff --git a/forms/source/xforms/model_ui.cxx b/forms/source/xforms/model_ui.cxx
index 2ce182031579..8591186b4bbb 100644
--- a/forms/source/xforms/model_ui.cxx
+++ b/forms/source/xforms/model_ui.cxx
@@ -365,7 +365,7 @@ OUString Model::getSubmissionName( const css::uno::Reference< ::css::beans::XPro
css::uno::Reference< ::css::beans::XPropertySet > Model::cloneBindingAsGhost( const css::uno::Reference< ::css::beans::XPropertySet > &xBinding )
{
// Create a new binding instance first...
- Binding *pBinding = new Binding();
+ rtl::Reference<Binding> pBinding = new Binding();
// ...and bump up the "deferred notification counter"
// to prevent this binding from contributing to the
@@ -504,7 +504,7 @@ css::uno::Reference<css::xforms::XModel> Model::newModel( const Reference<css::f
if( xModels.is()
&& ! xModels->hasByName( sName ) )
{
- Model* pModel = new Model();
+ rtl::Reference<Model> pModel = new Model();
xModel.set( pModel );
pModel->setID( sName );
@@ -672,7 +672,7 @@ css::uno::Reference< ::css::beans::XPropertySet > Model::getBindingForNode( cons
// appropriateness of the respective binding for this node. The
// best one will be used. If we don't find any and bCreate is set,
// then we will create a suitable binding.
- Binding* pBestBinding = nullptr;
+ rtl::Reference<Binding> pBestBinding;
sal_Int32 nBestScore = 0;
for( sal_Int32 n = 0; n < mxBindings->countItems(); n++ )
diff --git a/forms/source/xforms/submission.cxx b/forms/source/xforms/submission.cxx
index 5f7fdd007315..af59247c8668 100644
--- a/forms/source/xforms/submission.cxx
+++ b/forms/source/xforms/submission.cxx
@@ -416,23 +416,20 @@ void SAL_CALL Submission::submitWithInteraction(
if( _rxHandler.is() )
{
// laboriously create interaction request
- comphelper::OInteractionRequest* pRequest
+ rtl::Reference<comphelper::OInteractionRequest> pRequest
= new comphelper::OInteractionRequest(
makeAny( aInvalidDataException ) );
- Reference<XInteractionRequest> xRequest = pRequest;
- comphelper::OInteractionApprove* pContinue
+ rtl::Reference<comphelper::OInteractionApprove> pContinue
= new comphelper::OInteractionApprove();
- Reference<XInteractionContinuation> xContinue = pContinue;
- pRequest->addContinuation( xContinue );
+ pRequest->addContinuation( pContinue );
- comphelper::OInteractionDisapprove* pCancel
+ rtl::Reference<comphelper::OInteractionDisapprove> pCancel
= new comphelper::OInteractionDisapprove();
- Reference<XInteractionContinuation> xCancel = pCancel;
- pRequest->addContinuation( xCancel );
+ pRequest->addContinuation( pCancel );
// ask the handler...
- _rxHandler->handle( xRequest );
+ _rxHandler->handle( pRequest );
OSL_ENSURE( pContinue->wasSelected() || pCancel->wasSelected(),
"handler didn't select" );
diff --git a/forms/source/xforms/submission/replace.cxx b/forms/source/xforms/submission/replace.cxx
index e0823397d7d7..27e9fad49ab5 100644
--- a/forms/source/xforms/submission/replace.cxx
+++ b/forms/source/xforms/submission/replace.cxx
@@ -22,6 +22,7 @@
#include "serialization_app_xml.hxx"
#include <rtl/ustring.hxx>
+#include <rtl/ref.hxx>
#include <tools/diagnose_ex.h>
#include <comphelper/processfactory.hxx>
@@ -110,14 +111,14 @@ CSubmission::SubmissionResult CSubmission::replace(const OUString& aReplace, con
apSerialization->serialize();
// create a commandEnvironment and use the default interaction handler
- CCommandEnvironmentHelper *pHelper = new CCommandEnvironmentHelper;
+ rtl::Reference<CCommandEnvironmentHelper> pHelper = new CCommandEnvironmentHelper;
if( _xHandler.is() )
pHelper->m_aInteractionHandler = _xHandler;
else
pHelper->m_aInteractionHandler.set(
InteractionHandler::createWithParent(m_xContext, nullptr), UNO_QUERY_THROW);
- CProgressHandlerHelper *pProgressHelper = new CProgressHandlerHelper;
+ rtl::Reference<CProgressHandlerHelper> pProgressHelper = new CProgressHandlerHelper;
pHelper->m_aProgressHandler.set(pProgressHelper);
// UCB has ownership of environment...
diff --git a/forms/source/xforms/submission/submission_get.cxx b/forms/source/xforms/submission/submission_get.cxx
index 394c8b817486..956876199b3c 100644
--- a/forms/source/xforms/submission/submission_get.cxx
+++ b/forms/source/xforms/submission/submission_get.cxx
@@ -54,13 +54,13 @@ CSubmission::SubmissionResult CSubmissionGet::submit(const css::uno::Reference<
css::uno::Reference< XInputStream > aInStream = apSerialization->getInputStream();
// create a commandEnvironment and use the default interaction handler
- CCommandEnvironmentHelper *pHelper = new CCommandEnvironmentHelper;
+ rtl::Reference<CCommandEnvironmentHelper> pHelper = new CCommandEnvironmentHelper;
if( aInteractionHandler.is() )
pHelper->m_aInteractionHandler = aInteractionHandler;
else
pHelper->m_aInteractionHandler.set(
css::task::InteractionHandler::createWithParent(m_xContext, nullptr), UNO_QUERY_THROW);
- CProgressHandlerHelper *pProgressHelper = new CProgressHandlerHelper;
+ rtl::Reference<CProgressHandlerHelper> pProgressHelper = new CProgressHandlerHelper;
pHelper->m_aProgressHandler.set(pProgressHelper);
// UCB has ownership of environment...