summaryrefslogtreecommitdiff
path: root/xmlscript
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2016-05-23 13:53:42 +0200
committerNoel Grandin <noelgrandin@gmail.com>2016-05-24 06:54:06 +0000
commit111de438ea3e512a541281dc0716cc728ea8d152 (patch)
tree2c9ca866e79ed0cfc9299e553a87239345c515a6 /xmlscript
parentd3f21849ec8580fdb59a1f0b35453657f4050e0f (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 'xmlscript')
-rw-r--r--xmlscript/source/xmlflat_imexp/xmlbas_import.cxx44
-rw-r--r--xmlscript/source/xmlflat_imexp/xmlbas_import.hxx4
-rw-r--r--xmlscript/source/xmllib_imexp/imp_share.hxx4
-rw-r--r--xmlscript/source/xmllib_imexp/xmllib_import.cxx51
-rw-r--r--xmlscript/source/xmlmod_imexp/imp_share.hxx4
-rw-r--r--xmlscript/source/xmlmod_imexp/xmlmod_import.cxx23
6 files changed, 48 insertions, 82 deletions
diff --git a/xmlscript/source/xmlflat_imexp/xmlbas_import.cxx b/xmlscript/source/xmlflat_imexp/xmlbas_import.cxx
index 736afd5a6829..3c99d74a870d 100644
--- a/xmlscript/source/xmlflat_imexp/xmlbas_import.cxx
+++ b/xmlscript/source/xmlflat_imexp/xmlbas_import.cxx
@@ -43,23 +43,15 @@ namespace xmlscript
BasicElementBase::BasicElementBase( const OUString& rLocalName,
const Reference< xml::input::XAttributes >& xAttributes,
BasicElementBase* pParent, BasicImport* pImport )
- :m_pImport( pImport )
- ,m_pParent( pParent )
+ :m_xImport( pImport )
+ ,m_xParent( pParent )
,m_aLocalName( rLocalName )
,m_xAttributes( xAttributes )
{
- if ( m_pImport )
- m_pImport->acquire();
- if ( m_pParent )
- m_pParent->acquire();
}
BasicElementBase::~BasicElementBase()
{
- if ( m_pImport )
- m_pImport->release();
- if ( m_pParent )
- m_pParent->release();
}
bool BasicElementBase::getBoolAttr( bool* pRet, const OUString& rAttrName,
@@ -95,7 +87,7 @@ namespace xmlscript
Reference< xml::input::XElement > BasicElementBase::getParent()
throw (RuntimeException, std::exception)
{
- return static_cast< xml::input::XElement* >( m_pParent );
+ return m_xParent;
}
OUString BasicElementBase::getLocalName()
@@ -108,8 +100,8 @@ namespace xmlscript
throw (RuntimeException, std::exception)
{
sal_Int32 nId = -1;
- if ( m_pImport )
- nId = m_pImport->XMLNS_UID;
+ if ( m_xImport.is() )
+ nId = m_xImport->XMLNS_UID;
return nId;
}
@@ -168,7 +160,7 @@ void BasicElementBase::processingInstruction( const OUString& /*rTarget*/, const
{
Reference< xml::input::XElement > xElement;
- if ( nUid != m_pImport->XMLNS_UID )
+ if ( nUid != m_xImport->XMLNS_UID )
{
throw xml::sax::SAXException( "illegal namespace!", Reference< XInterface >(), Any() );
}
@@ -176,12 +168,12 @@ void BasicElementBase::processingInstruction( const OUString& /*rTarget*/, const
{
if ( xAttributes.is() )
{
- OUString aName = xAttributes->getValueByUidName( m_pImport->XMLNS_UID, "name" );
+ OUString aName = xAttributes->getValueByUidName( m_xImport->XMLNS_UID, "name" );
- OUString aStorageURL = xAttributes->getValueByUidName(m_pImport->XMLNS_XLINK_UID, "href" );
+ OUString aStorageURL = xAttributes->getValueByUidName(m_xImport->XMLNS_XLINK_UID, "href" );
bool bReadOnly = false;
- getBoolAttr( &bReadOnly,"readonly", xAttributes, m_pImport->XMLNS_UID );
+ getBoolAttr( &bReadOnly,"readonly", xAttributes, m_xImport->XMLNS_UID );
if ( m_xLibContainer.is() )
{
@@ -190,7 +182,7 @@ void BasicElementBase::processingInstruction( const OUString& /*rTarget*/, const
Reference< container::XNameAccess > xLib(
m_xLibContainer->createLibraryLink( aName, aStorageURL, bReadOnly ) );
if ( xLib.is() )
- xElement.set( new BasicElementBase( rLocalName, xAttributes, this, m_pImport ) );
+ xElement.set( new BasicElementBase( rLocalName, xAttributes, this, m_xImport.get() ) );
}
catch ( const container::ElementExistException& e )
{
@@ -209,10 +201,10 @@ void BasicElementBase::processingInstruction( const OUString& /*rTarget*/, const
if ( xAttributes.is() )
{
- OUString aName = xAttributes->getValueByUidName( m_pImport->XMLNS_UID, "name" );
+ OUString aName = xAttributes->getValueByUidName( m_xImport->XMLNS_UID, "name" );
bool bReadOnly = false;
- getBoolAttr( &bReadOnly, "readonly", xAttributes, m_pImport->XMLNS_UID );
+ getBoolAttr( &bReadOnly, "readonly", xAttributes, m_xImport->XMLNS_UID );
if ( m_xLibContainer.is() )
{
@@ -230,7 +222,7 @@ void BasicElementBase::processingInstruction( const OUString& /*rTarget*/, const
}
if ( xLib.is() )
- xElement.set( new BasicEmbeddedLibraryElement( rLocalName, xAttributes, this, m_pImport, m_xLibContainer, aName, bReadOnly ) );
+ xElement.set( new BasicEmbeddedLibraryElement( rLocalName, xAttributes, this, m_xImport.get(), m_xLibContainer, aName, bReadOnly ) );
}
catch ( const lang::IllegalArgumentException& e )
{
@@ -284,7 +276,7 @@ void BasicElementBase::processingInstruction( const OUString& /*rTarget*/, const
{
Reference< xml::input::XElement > xElement;
- if ( nUid != m_pImport->XMLNS_UID )
+ if ( nUid != m_xImport->XMLNS_UID )
{
throw xml::sax::SAXException( "illegal namespace!", Reference< XInterface >(), Any() );
}
@@ -292,10 +284,10 @@ void BasicElementBase::processingInstruction( const OUString& /*rTarget*/, const
{
if ( xAttributes.is() )
{
- OUString aName = xAttributes->getValueByUidName(m_pImport->XMLNS_UID, "name" );
+ OUString aName = xAttributes->getValueByUidName(m_xImport->XMLNS_UID, "name" );
if ( m_xLib.is() && !aName.isEmpty() )
- xElement.set( new BasicModuleElement( rLocalName, xAttributes, this, m_pImport, m_xLib, aName ) );
+ xElement.set( new BasicModuleElement( rLocalName, xAttributes, this, m_xImport.get(), m_xLib, aName ) );
}
}
else
@@ -336,7 +328,7 @@ void BasicElementBase::processingInstruction( const OUString& /*rTarget*/, const
Reference< xml::input::XElement > xElement;
- if ( nUid != m_pImport->XMLNS_UID )
+ if ( nUid != m_xImport->XMLNS_UID )
{
throw xml::sax::SAXException( "illegal namespace!", Reference< XInterface >(), Any() );
}
@@ -347,7 +339,7 @@ void BasicElementBase::processingInstruction( const OUString& /*rTarget*/, const
if ( xAttributes.is() )
{
if ( m_xLib.is() && !m_aName.isEmpty() )
- xElement.set( new BasicSourceCodeElement( rLocalName, xAttributes, this, m_pImport, m_xLib, m_aName ) );
+ xElement.set( new BasicSourceCodeElement( rLocalName, xAttributes, this, m_xImport.get(), m_xLib, m_aName ) );
}
}
else
diff --git a/xmlscript/source/xmlflat_imexp/xmlbas_import.hxx b/xmlscript/source/xmlflat_imexp/xmlbas_import.hxx
index 0eecb0dd1cd3..d38fa73f0ed3 100644
--- a/xmlscript/source/xmlflat_imexp/xmlbas_import.hxx
+++ b/xmlscript/source/xmlflat_imexp/xmlbas_import.hxx
@@ -43,8 +43,8 @@ namespace xmlscript
class BasicElementBase : public BasicElementBase_BASE
{
protected:
- BasicImport* m_pImport;
- BasicElementBase* m_pParent;
+ css::uno::Reference<BasicImport> m_xImport;
+ css::uno::Reference<BasicElementBase> m_xParent;
OUString m_aLocalName;
css::uno::Reference< css::xml::input::XAttributes > m_xAttributes;
diff --git a/xmlscript/source/xmllib_imexp/imp_share.hxx b/xmlscript/source/xmllib_imexp/imp_share.hxx
index a28fb2f7cd33..a1ce3561cc6c 100644
--- a/xmlscript/source/xmllib_imexp/imp_share.hxx
+++ b/xmlscript/source/xmllib_imexp/imp_share.hxx
@@ -155,8 +155,8 @@ class LibElementBase
: public ::cppu::WeakImplHelper< css::xml::input::XElement >
{
protected:
- LibraryImport * _pImport;
- LibElementBase * _pParent;
+ css::uno::Reference<LibraryImport> mxImport;
+ css::uno::Reference<LibElementBase> mxParent;
OUString _aLocalName;
css::uno::Reference< css::xml::input::XAttributes > _xAttributes;
diff --git a/xmlscript/source/xmllib_imexp/xmllib_import.cxx b/xmlscript/source/xmllib_imexp/xmllib_import.cxx
index 891919228d08..cc54d84cb4c7 100644
--- a/xmlscript/source/xmllib_imexp/xmllib_import.cxx
+++ b/xmlscript/source/xmllib_imexp/xmllib_import.cxx
@@ -33,7 +33,7 @@ namespace xmlscript
Reference< xml::input::XElement > LibElementBase::getParent()
throw (RuntimeException, std::exception)
{
- return static_cast< xml::input::XElement * >( _pParent );
+ return mxParent;
}
OUString LibElementBase::getLocalName()
@@ -45,7 +45,7 @@ OUString LibElementBase::getLocalName()
sal_Int32 LibElementBase::getUid()
throw (RuntimeException, std::exception)
{
- return _pImport->XMLNS_LIBRARY_UID;
+ return mxImport->XMLNS_LIBRARY_UID;
}
Reference< xml::input::XAttributes > LibElementBase::getAttributes()
@@ -88,28 +88,15 @@ LibElementBase::LibElementBase(
OUString const & rLocalName,
Reference< xml::input::XAttributes > const & xAttributes,
LibElementBase * pParent, LibraryImport * pImport )
- : _pImport( pImport )
- , _pParent( pParent )
+ : mxImport( pImport )
+ , mxParent( pParent )
, _aLocalName( rLocalName )
, _xAttributes( xAttributes )
{
- _pImport->acquire();
-
- if (_pParent)
- {
- _pParent->acquire();
- }
}
LibElementBase::~LibElementBase()
{
- _pImport->release();
-
- if (_pParent)
- {
- _pParent->release();
- }
-
SAL_INFO("xmlscript.xmllib", "LibElementBase::~LibElementBase(): " << _aLocalName );
}
@@ -182,7 +169,7 @@ Reference< xml::input::XElement > LibrariesElement::startChildElement(
Reference< xml::input::XAttributes > const & xAttributes )
throw (xml::sax::SAXException, RuntimeException, std::exception)
{
- if (_pImport->XMLNS_LIBRARY_UID != nUid)
+ if (mxImport->XMLNS_LIBRARY_UID != nUid)
{
throw xml::sax::SAXException( "illegal namespace!", Reference< XInterface >(), Any() );
}
@@ -192,14 +179,14 @@ Reference< xml::input::XElement > LibrariesElement::startChildElement(
LibDescriptor aDesc;
aDesc.bLink = aDesc.bReadOnly = aDesc.bPasswordProtected = aDesc.bPreload = false;
- aDesc.aName = xAttributes->getValueByUidName(_pImport->XMLNS_LIBRARY_UID, "name" );
- aDesc.aStorageURL = xAttributes->getValueByUidName( _pImport->XMLNS_XLINK_UID, "href" );
- getBoolAttr(&aDesc.bLink, "link", xAttributes, _pImport->XMLNS_LIBRARY_UID );
- getBoolAttr(&aDesc.bReadOnly, "readonly", xAttributes, _pImport->XMLNS_LIBRARY_UID );
- getBoolAttr(&aDesc.bPasswordProtected, "passwordprotected", xAttributes, _pImport->XMLNS_LIBRARY_UID );
+ aDesc.aName = xAttributes->getValueByUidName(mxImport->XMLNS_LIBRARY_UID, "name" );
+ aDesc.aStorageURL = xAttributes->getValueByUidName( mxImport->XMLNS_XLINK_UID, "href" );
+ getBoolAttr(&aDesc.bLink, "link", xAttributes, mxImport->XMLNS_LIBRARY_UID );
+ getBoolAttr(&aDesc.bReadOnly, "readonly", xAttributes, mxImport->XMLNS_LIBRARY_UID );
+ getBoolAttr(&aDesc.bPasswordProtected, "passwordprotected", xAttributes, mxImport->XMLNS_LIBRARY_UID );
mLibDescriptors.push_back( aDesc );
- return new LibraryElement( rLocalName, xAttributes, this, _pImport );
+ return new LibraryElement( rLocalName, xAttributes, this, mxImport.get() );
}
else
{
@@ -210,13 +197,13 @@ Reference< xml::input::XElement > LibrariesElement::startChildElement(
void LibrariesElement::endElement()
throw (xml::sax::SAXException, RuntimeException, std::exception)
{
- sal_Int32 nLibCount = _pImport->mpLibArray->mnLibCount = (sal_Int32)mLibDescriptors.size();
- _pImport->mpLibArray->mpLibs = new LibDescriptor[ nLibCount ];
+ sal_Int32 nLibCount = mxImport->mpLibArray->mnLibCount = (sal_Int32)mLibDescriptors.size();
+ mxImport->mpLibArray->mpLibs = new LibDescriptor[ nLibCount ];
for( sal_Int32 i = 0 ; i < nLibCount ; i++ )
{
const LibDescriptor& rLib = mLibDescriptors[i];
- _pImport->mpLibArray->mpLibs[i] = rLib;
+ mxImport->mpLibArray->mpLibs[i] = rLib;
}
}
@@ -226,18 +213,18 @@ Reference< xml::input::XElement > LibraryElement::startChildElement(
Reference< xml::input::XAttributes > const & xAttributes )
throw (xml::sax::SAXException, RuntimeException, std::exception)
{
- if (_pImport->XMLNS_LIBRARY_UID != nUid)
+ if (mxImport->XMLNS_LIBRARY_UID != nUid)
{
throw xml::sax::SAXException( "illegal namespace!", Reference< XInterface >(), Any() );
}
// library
else if ( rLocalName == "element" )
{
- OUString aValue( xAttributes->getValueByUidName(_pImport->XMLNS_LIBRARY_UID, "name" ) );
+ OUString aValue( xAttributes->getValueByUidName(mxImport->XMLNS_LIBRARY_UID, "name" ) );
if (!aValue.isEmpty())
mElements.push_back( aValue );
- return new LibElementBase( rLocalName, xAttributes, this, _pImport );
+ return new LibElementBase( rLocalName, xAttributes, this, mxImport.get() );
}
else
{
@@ -254,9 +241,9 @@ void LibraryElement::endElement()
for( sal_Int32 i = 0 ; i < nElementCount ; i++ )
pElementNames[i] = mElements[i];
- LibDescriptor* pLib = _pImport->mpLibDesc;
+ LibDescriptor* pLib = mxImport->mpLibDesc;
if( !pLib )
- pLib = &static_cast< LibrariesElement* >( _pParent )->mLibDescriptors.back();
+ pLib = &static_cast< LibrariesElement* >( mxParent.get() )->mLibDescriptors.back();
pLib->aElementNames = aElementNames;
}
diff --git a/xmlscript/source/xmlmod_imexp/imp_share.hxx b/xmlscript/source/xmlmod_imexp/imp_share.hxx
index 05ca0944ce04..b37b865971d5 100644
--- a/xmlscript/source/xmlmod_imexp/imp_share.hxx
+++ b/xmlscript/source/xmlmod_imexp/imp_share.hxx
@@ -85,8 +85,8 @@ class ModuleElement
: public ::cppu::WeakImplHelper< css::xml::input::XElement >
{
protected:
- ModuleImport * _pImport;
- ModuleElement * _pParent;
+ css::uno::Reference<ModuleImport> mxImport;
+ css::uno::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..0fdc1174c5b7 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;
}
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 );
}