diff options
author | Noel Grandin <noel@peralex.com> | 2016-06-01 16:22:29 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2016-06-06 07:01:34 +0000 |
commit | 0323253a7c67316cb96e4a64792ab4fe74aac1ca (patch) | |
tree | 81787c4ae44ff778aa41e12574cd60a624c9277b /xmlscript/source/xmlmod_imexp | |
parent | 4d666f5092d7c4f2ece9702dda4d874e44cdc6f7 (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 'xmlscript/source/xmlmod_imexp')
-rw-r--r-- | xmlscript/source/xmlmod_imexp/imp_share.hxx | 5 | ||||
-rw-r--r-- | xmlscript/source/xmlmod_imexp/xmlmod_import.cxx | 23 |
2 files changed, 8 insertions, 20 deletions
diff --git a/xmlscript/source/xmlmod_imexp/imp_share.hxx b/xmlscript/source/xmlmod_imexp/imp_share.hxx index 05ca0944ce04..6a1bede592fb 100644 --- a/xmlscript/source/xmlmod_imexp/imp_share.hxx +++ b/xmlscript/source/xmlmod_imexp/imp_share.hxx @@ -24,6 +24,7 @@ #include <cppuhelper/implbase.hxx> #include <rtl/ustrbuf.hxx> +#include <rtl/ref.hxx> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/container/XNameContainer.hpp> @@ -85,8 +86,8 @@ class ModuleElement : public ::cppu::WeakImplHelper< css::xml::input::XElement > { protected: - ModuleImport * _pImport; - ModuleElement * _pParent; + rtl::Reference<ModuleImport> mxImport; + rtl::Reference<ModuleElement> mxParent; OUString _aLocalName; css::uno::Reference< css::xml::input::XAttributes > _xAttributes; diff --git a/xmlscript/source/xmlmod_imexp/xmlmod_import.cxx b/xmlscript/source/xmlmod_imexp/xmlmod_import.cxx index f724ff7593ba..e9f9869ef6cf 100644 --- a/xmlscript/source/xmlmod_imexp/xmlmod_import.cxx +++ b/xmlscript/source/xmlmod_imexp/xmlmod_import.cxx @@ -33,7 +33,7 @@ namespace xmlscript Reference< xml::input::XElement > ModuleElement::getParent() throw (RuntimeException, std::exception) { - return static_cast< xml::input::XElement * >( _pParent ); + return mxParent.get(); } OUString ModuleElement::getLocalName() throw (RuntimeException, std::exception) @@ -43,7 +43,7 @@ OUString ModuleElement::getLocalName() sal_Int32 ModuleElement::getUid() throw (RuntimeException, std::exception) { - return _pImport->XMLNS_SCRIPT_UID; + return mxImport->XMLNS_SCRIPT_UID; } Reference< xml::input::XAttributes > ModuleElement::getAttributes() throw (RuntimeException, std::exception) @@ -73,7 +73,7 @@ void ModuleElement::processingInstruction( void ModuleElement::endElement() throw (xml::sax::SAXException, RuntimeException, std::exception) { - _pImport->mrModuleDesc.aCode = _strBuffer.makeStringAndClear(); + mxImport->mrModuleDesc.aCode = _strBuffer.makeStringAndClear(); } Reference< xml::input::XElement > ModuleElement::startChildElement( @@ -88,28 +88,15 @@ ModuleElement::ModuleElement( OUString const & rLocalName, Reference< xml::input::XAttributes > const & xAttributes, ModuleElement * pParent, ModuleImport * pImport ) - : _pImport( pImport ) - , _pParent( pParent ) + : mxImport( pImport ) + , mxParent( pParent ) , _aLocalName( rLocalName ) , _xAttributes( xAttributes ) { - _pImport->acquire(); - - if (_pParent) - { - _pParent->acquire(); - } } ModuleElement::~ModuleElement() { - _pImport->release(); - - if (_pParent) - { - _pParent->release(); - } - SAL_INFO("xmlscript.xmlmod", "ModuleElement::~ModuleElement(): " << _aLocalName ); } |