diff options
author | Noel Grandin <noel@peralex.com> | 2016-05-24 11:02:42 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2016-05-24 11:02:42 +0200 |
commit | 95d20a3799998b9816bd2e8aebdbc96c61cead3e (patch) | |
tree | 8206ecc848631432cb8b027d5e780483734f808a /svtools | |
parent | 3caf31b05d7bbf3d50a1bbda6c8b95982cb5c2b5 (diff) |
Revert "remove some manual ref-counting"
until I have a better understanding of the UNO reference
counting.
This reverts commit 111de438ea3e512a541281dc0716cc728ea8d152.
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, 24 insertions, 10 deletions
diff --git a/svtools/source/inc/unoiface.hxx b/svtools/source/inc/unoiface.hxx index 485df3f70cf7..bbe2f6a17243 100644 --- a/svtools/source/inc/unoiface.hxx +++ b/svtools/source/inc/unoiface.hxx @@ -170,7 +170,7 @@ public: class SVTXFormattedField : public VCLXSpinField { protected: - css::uno::Reference<SvNumberFormatsSupplierObj> m_xCurrentSupplier; + SvNumberFormatsSupplierObj* m_pCurrentSupplier; bool bIsStandardSupplier; sal_Int32 nKeyToSetDelayed; diff --git a/svtools/source/uno/unoiface.cxx b/svtools/source/uno/unoiface.cxx index 4563803745ee..595106ee2f7c 100644 --- a/svtools/source/uno/unoiface.cxx +++ b/svtools/source/uno/unoiface.cxx @@ -810,7 +810,8 @@ void VCLXFileControl::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) SVTXFormattedField::SVTXFormattedField() - :bIsStandardSupplier(true) + :m_pCurrentSupplier(nullptr) + ,bIsStandardSupplier(true) ,nKeyToSetDelayed(-1) { } @@ -818,6 +819,11 @@ SVTXFormattedField::SVTXFormattedField() SVTXFormattedField::~SVTXFormattedField() { + if (m_pCurrentSupplier) + { + m_pCurrentSupplier->release(); + m_pCurrentSupplier = nullptr; + } } @@ -1023,7 +1029,7 @@ css::uno::Any SVTXFormattedField::getProperty( const OUString& PropertyName ) th css::uno::Reference< css::util::XNumberFormatsSupplier > SVTXFormattedField::getFormatsSupplier() const { - return m_xCurrentSupplier; + return css::uno::Reference< css::util::XNumberFormatsSupplier > (m_pCurrentSupplier); } css::uno::Any SVTXFormattedField::convertEffectiveValue(const css::uno::Any& rValue) @@ -1311,12 +1317,15 @@ void SVTXFormattedField::setFormatsSupplier(const css::uno::Reference< css::util if (!pNew) return; // TODO : how to process ? - m_xCurrentSupplier = pNew; + if (m_pCurrentSupplier) + m_pCurrentSupplier->release(); + m_pCurrentSupplier = pNew; + m_pCurrentSupplier->acquire(); if (pField) { // save the actual value css::uno::Any aCurrent = GetValue(); - pField->SetFormatter(m_xCurrentSupplier->GetNumberFormatter(), false); + pField->SetFormatter(m_pCurrentSupplier->GetNumberFormatter(), false); if (nKeyToSetDelayed != -1) { pField->SetFormatKey(nKeyToSetDelayed); diff --git a/svtools/source/uno/unoimap.cxx b/svtools/source/uno/unoimap.cxx index e5805c5dafc9..8dee26a8741b 100644 --- a/svtools/source/uno/unoimap.cxx +++ b/svtools/source/uno/unoimap.cxx @@ -79,7 +79,7 @@ public: IMapObject* createIMapObject() const; - css::uno::Reference<SvMacroTableEventDescriptor> mxEvents; + SvMacroTableEventDescriptor* mpEvents; // overriden helpers from PropertySetHelper virtual void _setPropertyValues( const PropertyMapEntry** ppEntries, const Any* pValues ) throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException ) override; @@ -186,7 +186,8 @@ SvUnoImageMapObject::SvUnoImageMapObject( sal_uInt16 nType, const SvEventDescrip , mbIsActive( true ) , mnRadius( 0 ) { - mxEvents = new SvMacroTableEventDescriptor( pSupportedMacroItems ); + mpEvents = new SvMacroTableEventDescriptor( pSupportedMacroItems ); + mpEvents->acquire(); } SvUnoImageMapObject::SvUnoImageMapObject( const IMapObject& rMapObject, const SvEventDescription* pSupportedMacroItems ) @@ -242,11 +243,13 @@ SvUnoImageMapObject::SvUnoImageMapObject( const IMapObject& rMapObject, const Sv } } - mxEvents = new SvMacroTableEventDescriptor( rMapObject.GetMacroTable(), pSupportedMacroItems ); + mpEvents = new SvMacroTableEventDescriptor( rMapObject.GetMacroTable(), pSupportedMacroItems ); + mpEvents->acquire(); } SvUnoImageMapObject::~SvUnoImageMapObject() throw() { + mpEvents->release(); } IMapObject* SvUnoImageMapObject::createIMapObject() const @@ -294,7 +297,7 @@ IMapObject* SvUnoImageMapObject::createIMapObject() const } SvxMacroTableDtor aMacroTable; - mxEvents->copyMacrosIntoTable(aMacroTable); + mpEvents->copyMacrosIntoTable(aMacroTable); pNewIMapObject->SetMacroTable( aMacroTable ); return pNewIMapObject; @@ -509,7 +512,9 @@ void SvUnoImageMapObject::_getPropertyValues( const PropertyMapEntry** ppEntries Reference< XNameReplace > SAL_CALL SvUnoImageMapObject::getEvents() throw( RuntimeException, std::exception ) { - return mxEvents; + // try weak reference first + Reference< XNameReplace > xEvents( mpEvents ); + return xEvents; } |