diff options
author | Noel Grandin <noel@peralex.com> | 2016-05-23 13:53:42 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2016-05-24 06:54:06 +0000 |
commit | 111de438ea3e512a541281dc0716cc728ea8d152 (patch) | |
tree | 2c9ca866e79ed0cfc9299e553a87239345c515a6 /svtools | |
parent | d3f21849ec8580fdb59a1f0b35453657f4050e0f (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: Ie1abeaed75c1f861df185e3bde680272dbadc97f
Reviewed-on: https://gerrit.libreoffice.org/25363
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/inc/unoiface.hxx | 2 | ||||
-rw-r--r-- | svtools/source/uno/unoiface.cxx | 17 | ||||
-rw-r--r-- | svtools/source/uno/unoimap.cxx | 15 |
3 files changed, 10 insertions, 24 deletions
diff --git a/svtools/source/inc/unoiface.hxx b/svtools/source/inc/unoiface.hxx index bbe2f6a17243..485df3f70cf7 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; + css::uno::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..4563803745ee 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; } 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..e5805c5dafc9 100644 --- a/svtools/source/uno/unoimap.cxx +++ b/svtools/source/uno/unoimap.cxx @@ -79,7 +79,7 @@ public: IMapObject* createIMapObject() const; - SvMacroTableEventDescriptor* mpEvents; + css::uno::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; } |