summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2014-05-28 14:29:18 +0200
committerStephan Bergmann <sbergman@redhat.com>2014-05-28 14:34:12 +0200
commita77a7f608316f647ed8736e9474ff8f4f432f08b (patch)
treec1ba361d1ba08621526bd5dedac08073bce94fe8 /basic
parentb8a329989cead1db2e4b11ee41368010e55a7ce8 (diff)
Fix memory leak
...by using css::uno::Type instead of a naked typelib_TypeDescription. Change-Id: I387692265e9e032cb5ed6519739ebb3307db6f28
Diffstat (limited to 'basic')
-rw-r--r--basic/source/classes/sbunoobj.cxx44
-rw-r--r--basic/source/inc/sbunoobj.hxx7
2 files changed, 19 insertions, 32 deletions
diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx
index 3c4d1b390a47..d1b52baed723 100644
--- a/basic/source/classes/sbunoobj.cxx
+++ b/basic/source/classes/sbunoobj.cxx
@@ -2401,9 +2401,7 @@ SbUnoObject::SbUnoObject( const OUString& aName_, const Any& aUnoObj_ )
aClassName_ = aUnoObj_.getValueType().getTypeName();
bSetClassName = true;
}
- typelib_TypeDescription * pDeclTD = 0;
- typelib_typedescription_getByName( &pDeclTD, maTmpUnoObj.getValueTypeName().pData );
- StructRefInfo aThisStruct( maTmpUnoObj, pDeclTD, 0 );
+ StructRefInfo aThisStruct( maTmpUnoObj, maTmpUnoObj.getValueType(), 0 );
maStructInfo.reset( new SbUnoStructRefObject( GetName(), aThisStruct ) );
}
else if( eType == TypeClass_INTERFACE )
@@ -4776,16 +4774,19 @@ Any StructRefInfo::getValue()
Any aRet;
uno_any_destruct(
&aRet, reinterpret_cast< uno_ReleaseFunc >(cpp_release) );
+ typelib_TypeDescription * pTD = 0;
+ maType.getDescription(&pTD);
uno_any_construct(
- &aRet, getInst(), mpTD,
+ &aRet, getInst(), pTD,
reinterpret_cast< uno_AcquireFunc >(cpp_acquire) );
+ typelib_typedescription_release(pTD);
return aRet;
}
void StructRefInfo::setValue( const Any& rValue )
{
uno_type_assignData( getInst(),
- mpTD->pWeakRef,
+ maType.getTypeLibType(),
(void*)rValue.getValue(),
rValue.getValueTypeRef(),
reinterpret_cast< uno_QueryInterfaceFunc >(cpp_queryInterface),
@@ -4795,12 +4796,7 @@ void StructRefInfo::setValue( const Any& rValue )
OUString StructRefInfo::getTypeName() const
{
- OUString sTypeName;
- if ( mpTD )
- {
- sTypeName = mpTD->pTypeName;
- }
- return sTypeName;
+ return maType.getTypeName();
}
void* StructRefInfo::getInst()
@@ -4810,10 +4806,7 @@ void* StructRefInfo::getInst()
TypeClass StructRefInfo::getTypeClass() const
{
- TypeClass t = TypeClass_VOID;
- if ( mpTD )
- t = (TypeClass)mpTD->eTypeClass;
- return t;
+ return maType.getTypeClass();
}
SbUnoStructRefObject::SbUnoStructRefObject( const OUString& aName_, const StructRefInfo& rMemberInfo ) : SbxObject( aName_ ), maMemberInfo( rMemberInfo ), mbMemberCacheInit( false )
@@ -4832,7 +4825,8 @@ void SbUnoStructRefObject::initMemberCache()
if ( mbMemberCacheInit )
return;
sal_Int32 nAll = 0;
- typelib_TypeDescription * pTD = maMemberInfo.getTD();
+ typelib_TypeDescription * pTD = 0;
+ maMemberInfo.getType().getDescription(&pTD);
typelib_CompoundTypeDescription * pCompTypeDescr = (typelib_CompoundTypeDescription *)pTD;
for ( ; pCompTypeDescr; pCompTypeDescr = pCompTypeDescr->pBaseTypeDescription )
nAll += pCompTypeDescr->nMembers;
@@ -4844,17 +4838,11 @@ void SbUnoStructRefObject::initMemberCache()
sal_Int32 * pMemberOffsets = pCompTypeDescr->pMemberOffsets;
for ( sal_Int32 nPos = pCompTypeDescr->nMembers; nPos--; )
{
- typelib_TypeDescription * pMemberTD = 0;
- TYPELIB_DANGER_GET( &pMemberTD, ppTypeRefs[nPos] );
- OSL_ENSURE( pMemberTD, "### cannot get field in struct!" );
- if (pMemberTD)
- {
- OUString aName( ppNames[nPos] );
- TYPELIB_DANGER_RELEASE( pMemberTD );
- maFields[ aName ] = new StructRefInfo( maMemberInfo.getRootAnyRef(), pMemberTD, maMemberInfo.getPos() + pMemberOffsets[nPos] );
- }
+ OUString aName( ppNames[nPos] );
+ maFields[ aName ] = new StructRefInfo( maMemberInfo.getRootAnyRef(), ppTypeRefs[nPos], maMemberInfo.getPos() + pMemberOffsets[nPos] );
}
}
+ typelib_typedescription_release(pTD);
mbMemberCacheInit = true;
}
@@ -5093,15 +5081,15 @@ StructRefInfo SbUnoStructRefObject::getStructMember( const OUString& rMemberName
}
StructFieldInfo::iterator it = maFields.find( rMemberName );
- typelib_TypeDescription * pFoundTD = NULL;
+ css::uno::Type aFoundType;
sal_Int32 nFoundPos = -1;
if ( it != maFields.end() )
{
- pFoundTD = it->second->getTD();
+ aFoundType = it->second->getType();
nFoundPos = it->second->getPos();
}
- StructRefInfo aRet( maMemberInfo.getRootAnyRef(), pFoundTD, nFoundPos );
+ StructRefInfo aRet( maMemberInfo.getRootAnyRef(), aFoundType, nFoundPos );
return aRet;
}
diff --git a/basic/source/inc/sbunoobj.hxx b/basic/source/inc/sbunoobj.hxx
index 84b26696060c..29033ff984c6 100644
--- a/basic/source/inc/sbunoobj.hxx
+++ b/basic/source/inc/sbunoobj.hxx
@@ -40,15 +40,14 @@
class StructRefInfo
{
- StructRefInfo();
com::sun::star::uno::Any& maAny;
- typelib_TypeDescription* mpTD;
+ css::uno::Type maType;
sal_Int32 mnPos;
public:
- StructRefInfo( com::sun::star::uno::Any& aAny, typelib_TypeDescription* pTD, sal_Int32 nPos ) : maAny( aAny ), mpTD( pTD ), mnPos( nPos ) {}
+ StructRefInfo( com::sun::star::uno::Any& aAny, css::uno::Type const & rType, sal_Int32 nPos ) : maAny( aAny ), maType( rType ), mnPos( nPos ) {}
sal_Int32 getPos() const { return mnPos; }
- typelib_TypeDescription* getTD() const { return mpTD; }
+ css::uno::Type getType() const { return maType; }
OUString getTypeName() const;
com::sun::star::uno::Any& getRootAnyRef() { return maAny; };