summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2016-06-01 16:22:29 +0200
committerNoel Grandin <noelgrandin@gmail.com>2016-06-06 07:01:34 +0000
commit0323253a7c67316cb96e4a64792ab4fe74aac1ca (patch)
tree81787c4ae44ff778aa41e12574cd60a624c9277b /svtools
parent4d666f5092d7c4f2ece9702dda4d874e44cdc6f7 (diff)
remove some manual ref-counting
triggered when I noticed a class doing acquire() in the constructor and then release() in the destructor. found mostly by git grep -n -B5 -e '->release()' Change-Id: I96e43a3d30ffd9ae9a34275f24cd914d8f7b026f Reviewed-on: https://gerrit.libreoffice.org/25806 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/inc/unoiface.hxx2
-rw-r--r--svtools/source/uno/unoiface.cxx17
-rw-r--r--svtools/source/uno/unoimap.cxx15
3 files changed, 10 insertions, 24 deletions
diff --git a/svtools/source/inc/unoiface.hxx b/svtools/source/inc/unoiface.hxx
index bbe2f6a17243..7b9bc25f96b8 100644
--- a/svtools/source/inc/unoiface.hxx
+++ b/svtools/source/inc/unoiface.hxx
@@ -170,7 +170,7 @@ public:
class SVTXFormattedField : public VCLXSpinField
{
protected:
- SvNumberFormatsSupplierObj* m_pCurrentSupplier;
+ rtl::Reference<SvNumberFormatsSupplierObj> m_xCurrentSupplier;
bool bIsStandardSupplier;
sal_Int32 nKeyToSetDelayed;
diff --git a/svtools/source/uno/unoiface.cxx b/svtools/source/uno/unoiface.cxx
index 595106ee2f7c..0e14c9a78375 100644
--- a/svtools/source/uno/unoiface.cxx
+++ b/svtools/source/uno/unoiface.cxx
@@ -810,8 +810,7 @@ void VCLXFileControl::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
SVTXFormattedField::SVTXFormattedField()
- :m_pCurrentSupplier(nullptr)
- ,bIsStandardSupplier(true)
+ :bIsStandardSupplier(true)
,nKeyToSetDelayed(-1)
{
}
@@ -819,11 +818,6 @@ SVTXFormattedField::SVTXFormattedField()
SVTXFormattedField::~SVTXFormattedField()
{
- if (m_pCurrentSupplier)
- {
- m_pCurrentSupplier->release();
- m_pCurrentSupplier = nullptr;
- }
}
@@ -1029,7 +1023,7 @@ css::uno::Any SVTXFormattedField::getProperty( const OUString& PropertyName ) th
css::uno::Reference< css::util::XNumberFormatsSupplier > SVTXFormattedField::getFormatsSupplier() const
{
- return css::uno::Reference< css::util::XNumberFormatsSupplier > (m_pCurrentSupplier);
+ return m_xCurrentSupplier.get();
}
css::uno::Any SVTXFormattedField::convertEffectiveValue(const css::uno::Any& rValue)
@@ -1317,15 +1311,12 @@ void SVTXFormattedField::setFormatsSupplier(const css::uno::Reference< css::util
if (!pNew)
return; // TODO : how to process ?
- if (m_pCurrentSupplier)
- m_pCurrentSupplier->release();
- m_pCurrentSupplier = pNew;
- m_pCurrentSupplier->acquire();
+ m_xCurrentSupplier = pNew;
if (pField)
{
// save the actual value
css::uno::Any aCurrent = GetValue();
- pField->SetFormatter(m_pCurrentSupplier->GetNumberFormatter(), false);
+ pField->SetFormatter(m_xCurrentSupplier->GetNumberFormatter(), false);
if (nKeyToSetDelayed != -1)
{
pField->SetFormatKey(nKeyToSetDelayed);
diff --git a/svtools/source/uno/unoimap.cxx b/svtools/source/uno/unoimap.cxx
index 8dee26a8741b..b7652417d041 100644
--- a/svtools/source/uno/unoimap.cxx
+++ b/svtools/source/uno/unoimap.cxx
@@ -79,7 +79,7 @@ public:
IMapObject* createIMapObject() const;
- SvMacroTableEventDescriptor* mpEvents;
+ rtl::Reference<SvMacroTableEventDescriptor> mxEvents;
// overriden helpers from PropertySetHelper
virtual void _setPropertyValues( const PropertyMapEntry** ppEntries, const Any* pValues ) throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException ) override;
@@ -186,8 +186,7 @@ SvUnoImageMapObject::SvUnoImageMapObject( sal_uInt16 nType, const SvEventDescrip
, mbIsActive( true )
, mnRadius( 0 )
{
- mpEvents = new SvMacroTableEventDescriptor( pSupportedMacroItems );
- mpEvents->acquire();
+ mxEvents = new SvMacroTableEventDescriptor( pSupportedMacroItems );
}
SvUnoImageMapObject::SvUnoImageMapObject( const IMapObject& rMapObject, const SvEventDescription* pSupportedMacroItems )
@@ -243,13 +242,11 @@ SvUnoImageMapObject::SvUnoImageMapObject( const IMapObject& rMapObject, const Sv
}
}
- mpEvents = new SvMacroTableEventDescriptor( rMapObject.GetMacroTable(), pSupportedMacroItems );
- mpEvents->acquire();
+ mxEvents = new SvMacroTableEventDescriptor( rMapObject.GetMacroTable(), pSupportedMacroItems );
}
SvUnoImageMapObject::~SvUnoImageMapObject() throw()
{
- mpEvents->release();
}
IMapObject* SvUnoImageMapObject::createIMapObject() const
@@ -297,7 +294,7 @@ IMapObject* SvUnoImageMapObject::createIMapObject() const
}
SvxMacroTableDtor aMacroTable;
- mpEvents->copyMacrosIntoTable(aMacroTable);
+ mxEvents->copyMacrosIntoTable(aMacroTable);
pNewIMapObject->SetMacroTable( aMacroTable );
return pNewIMapObject;
@@ -512,9 +509,7 @@ void SvUnoImageMapObject::_getPropertyValues( const PropertyMapEntry** ppEntries
Reference< XNameReplace > SAL_CALL SvUnoImageMapObject::getEvents()
throw( RuntimeException, std::exception )
{
- // try weak reference first
- Reference< XNameReplace > xEvents( mpEvents );
- return xEvents;
+ return mxEvents.get();
}