You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by al...@apache.org on 2012/06/26 15:36:33 UTC
svn commit: r1354011 - in /incubator/ooo/trunk/main: sc/source/core/data/
sc/source/filter/xml/ sfx2/source/doc/ svl/inc/svl/ svl/source/items/
sw/inc/ sw/source/core/unocore/ sw/source/ui/app/
Author: alg
Date: Tue Jun 26 13:36:31 2012
New Revision: 1354011
URL: http://svn.apache.org/viewvc?rev=1354011&view=rev
Log:
#120077# Memory leak fixed in ScXMLFontAutoStylePool_Impl, also chekced and fixed memory leaks caused by not deleting SfxStyleSheetIterator instances.
Found by: Chao Huang
Patch by: Chao Huang
Review by: alg
Modified:
incubator/ooo/trunk/main/sc/source/core/data/patattr.cxx
incubator/ooo/trunk/main/sc/source/core/data/stlsheet.cxx
incubator/ooo/trunk/main/sc/source/filter/xml/xmlfonte.cxx
incubator/ooo/trunk/main/sfx2/source/doc/objcont.cxx
incubator/ooo/trunk/main/svl/inc/svl/style.hxx
incubator/ooo/trunk/main/svl/source/items/style.cxx
incubator/ooo/trunk/main/sw/inc/docstyle.hxx
incubator/ooo/trunk/main/sw/source/core/unocore/unostyle.cxx
incubator/ooo/trunk/main/sw/source/ui/app/docstyle.cxx
Modified: incubator/ooo/trunk/main/sc/source/core/data/patattr.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/core/data/patattr.cxx?rev=1354011&r1=1354010&r2=1354011&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/core/data/patattr.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/core/data/patattr.cxx Tue Jun 26 13:36:31 2012
@@ -1187,16 +1187,17 @@ void ScPatternAttr::UpdateStyleSheet()
{
if (pName)
{
- pStyle = (ScStyleSheet*)pDoc->GetStyleSheetPool()->Find(*pName, SFX_STYLE_FAMILY_PARA);
+ pStyle = dynamic_cast< ScStyleSheet* >(pDoc->GetStyleSheetPool()->Find(*pName, SFX_STYLE_FAMILY_PARA));
// wenn Style nicht gefunden, Standard nehmen,
// damit keine leere Anzeige im Toolbox-Controller
//! es wird vorausgesetzt, dass "Standard" immer der erste Eintrag ist!
if (!pStyle)
{
- SfxStyleSheetIterator* pIter = pDoc->GetStyleSheetPool()->CreateIterator(
- SFX_STYLE_FAMILY_PARA, SFXSTYLEBIT_ALL );
- pStyle = (ScStyleSheet*)pIter->First();
+ // #i120077# memory leak
+ SfxStyleSheetIterator aIter(pDoc->GetStyleSheetPool(), SFX_STYLE_FAMILY_PARA, SFXSTYLEBIT_ALL);
+
+ pStyle = dynamic_cast< ScStyleSheet* >(aIter.First());
}
if (pStyle)
Modified: incubator/ooo/trunk/main/sc/source/core/data/stlsheet.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/core/data/stlsheet.cxx?rev=1354011&r1=1354010&r2=1354011&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/core/data/stlsheet.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/core/data/stlsheet.cxx Tue Jun 26 13:36:31 2012
@@ -119,9 +119,12 @@ sal_Bool __EXPORT ScStyleSheet::SetParen
SfxStyleSheetBase* pStyle = rPool.Find( aEffName, nFamily );
if (!pStyle)
{
- SfxStyleSheetIterator* pIter = rPool.CreateIterator( nFamily, SFXSTYLEBIT_ALL );
- pStyle = pIter->First();
- if (pStyle)
+ // memory leak #i120077#
+ SfxStyleSheetIterator aIter(&rPool, nFamily, SFXSTYLEBIT_ALL);
+
+ pStyle = aIter.First();
+
+ if (pStyle)
aEffName = pStyle->GetName();
}
Modified: incubator/ooo/trunk/main/sc/source/filter/xml/xmlfonte.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/filter/xml/xmlfonte.cxx?rev=1354011&r1=1354010&r2=1354011&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/filter/xml/xmlfonte.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/filter/xml/xmlfonte.cxx Tue Jun 26 13:36:31 2012
@@ -45,11 +45,14 @@
class ScXMLFontAutoStylePool_Impl: public XMLFontAutoStylePool
{
- void AddFontItems(sal_uInt16* pWhichIds, sal_uInt8 nIdCount, const SfxItemPool* pItemPool, const sal_Bool bExportDefaults);
- public:
+private:
+ // #i120077# remember owned pool
+ SfxItemPool* mpEditEnginePool;
+ void AddFontItems(sal_uInt16* pWhichIds, sal_uInt8 nIdCount, const SfxItemPool* pItemPool, const sal_Bool bExportDefaults);
+public:
ScXMLFontAutoStylePool_Impl( ScXMLExport& rExport );
-
+ virtual ~ScXMLFontAutoStylePool_Impl();
};
void ScXMLFontAutoStylePool_Impl::AddFontItems(sal_uInt16* pWhichIds, sal_uInt8 nIdCount, const SfxItemPool* pItemPool, const sal_Bool bExportDefaults)
@@ -83,7 +86,8 @@ void ScXMLFontAutoStylePool_Impl::AddFon
ScXMLFontAutoStylePool_Impl::ScXMLFontAutoStylePool_Impl(
ScXMLExport& rExportP ) :
- XMLFontAutoStylePool( rExportP )
+ XMLFontAutoStylePool( rExportP ),
+ mpEditEnginePool(0)
{
sal_uInt16 aWhichIds[3] = { ATTR_FONT, ATTR_CJK_FONT,
ATTR_CTL_FONT };
@@ -96,14 +100,19 @@ ScXMLFontAutoStylePool_Impl::ScXMLFontAu
AddFontItems(aWhichIds, 3, pItemPool, sal_True);
const SfxItemPool* pEditPool(rExportP.GetDocument()->GetEditPool());
AddFontItems(aEditWhichIds, 3, pEditPool, sal_False);
-
- SfxStyleSheetIterator* pItr(rExportP.GetDocument() ? rExportP.GetDocument()->GetStyleSheetPool()->CreateIterator(SFX_STYLE_FAMILY_PAGE, 0xFFFF) : NULL);
- if(pItr)
- {
- SfxStyleSheetBase* pStyle(pItr->First());
- SfxItemPool* pPageEditPool(EditEngine::CreatePool());
+
+ if(rExportP.GetDocument() && rExportP.GetDocument()->GetStyleSheetPool())
+ {
+ // memory leak #i120077#
+ SfxStyleSheetIterator aIter(rExportP.GetDocument()->GetStyleSheetPool(), SFX_STYLE_FAMILY_PAGE, 0xFFFF);
+ SfxStyleSheetBase* pStyle(aIter.First());
+
+ // #i120077# init pool and use it
+ mpEditEnginePool = EditEngine::CreatePool(); // memory leak #i120077#, to save the SfxItemPool obj into member data for releasing
+ SfxItemPool* pPageEditPool( mpEditEnginePool );
EditEngine aEditEngine(pPageEditPool);
- while (pStyle)
+
+ while (pStyle)
{
const SfxItemPool& rPagePool(pStyle->GetPool().GetPool());
for (sal_uInt8 j = 0; j < 4; ++j)
@@ -136,11 +145,19 @@ ScXMLFontAutoStylePool_Impl::ScXMLFontAu
}
}
}
- pStyle = pItr->Next();
+ pStyle = aIter.Next();
}
}
}
+ScXMLFontAutoStylePool_Impl::~ScXMLFontAutoStylePool_Impl()
+{
+ if(mpEditEnginePool)
+ {
+ // memory leak #i120077#
+ SfxItemPool::Free(mpEditEnginePool);
+ }
+}
XMLFontAutoStylePool* ScXMLExport::CreateFontAutoStylePool()
{
Modified: incubator/ooo/trunk/main/sfx2/source/doc/objcont.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sfx2/source/doc/objcont.cxx?rev=1354011&r1=1354010&r2=1354011&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sfx2/source/doc/objcont.cxx (original)
+++ incubator/ooo/trunk/main/sfx2/source/doc/objcont.cxx Tue Jun 26 13:36:31 2012
@@ -759,12 +759,16 @@ sal_Bool SfxObjectShell::Print
{
SfxStyleSheetBasePool *pStylePool = GetStyleSheetPool();
SetOrganizerSearchMask(pStylePool);
- SfxStyleSheetIterator* pIter = pStylePool->CreateIterator(
- pStylePool->GetSearchFamily(), pStylePool->GetSearchMask() );
- sal_uInt16 nStyles = pIter->Count();
- SfxStyleSheetBase *pStyle = pIter->First();
- if ( !pStyle )
- return sal_True;
+
+ // memory leak #i120077#
+ SfxStyleSheetIterator aIter(pStylePool, pStylePool->GetSearchFamily(), pStylePool->GetSearchMask());
+ sal_uInt16 nStyles = aIter.Count();
+ SfxStyleSheetBase *pStyle = aIter.First();
+
+ if ( !pStyle )
+ {
+ return sal_True;
+ }
// pepare adaptor for old style StartPage/EndPage printing
boost::shared_ptr< Printer > pPrinter( new Printer( rPrt.GetJobSetup() ) );
@@ -863,13 +867,12 @@ sal_Bool SfxObjectShell::Print
pPrinter->DrawText(aOutPos, aTmp);
aOutPos.Y() += pPrinter->GetTextHeight();
}
- pStyle = pIter->Next();
+ pStyle = aIter.Next();
}
pAdaptor->EndPage();
Printer::PrintJob( pController, rPrt.GetJobSetup() );
- delete pIter;
break;
}
default:
Modified: incubator/ooo/trunk/main/svl/inc/svl/style.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svl/inc/svl/style.hxx?rev=1354011&r1=1354010&r2=1354011&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svl/inc/svl/style.hxx (original)
+++ incubator/ooo/trunk/main/svl/inc/svl/style.hxx Tue Jun 26 13:36:31 2012
@@ -238,7 +238,6 @@ public:
SfxItemPool& GetPool();
const SfxItemPool& GetPool() const;
- virtual SfxStyleSheetIterator* CreateIterator(SfxStyleFamily, sal_uInt16 nMask);
virtual sal_uInt16 Count();
virtual SfxStyleSheetBase* operator[](sal_uInt16 nIdx);
Modified: incubator/ooo/trunk/main/svl/source/items/style.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svl/source/items/style.cxx?rev=1354011&r1=1354010&r2=1354011&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svl/source/items/style.cxx (original)
+++ incubator/ooo/trunk/main/svl/source/items/style.cxx Tue Jun 26 13:36:31 2012
@@ -587,7 +587,7 @@ SfxStyleSheetIterator& SfxStyleSheetBase
if( !rpIter || (rpIter->GetSearchMask() != nMask) || (rpIter->GetSearchFamily() != nSearchFamily) )
{
delete rpIter;
- rpIter = CreateIterator( nSearchFamily, nMask );
+ rpIter = new SfxStyleSheetIterator( this, nSearchFamily, nMask );
}
return *rpIter;
}
@@ -668,16 +668,6 @@ String SfxStyleSheetBasePool::GetStreamN
-SfxStyleSheetIterator* SfxStyleSheetBasePool::CreateIterator
-(
- SfxStyleFamily eFam,
- sal_uInt16 mask
-)
-{
- return new SfxStyleSheetIterator(this,eFam,mask);
-}
-
-
SfxStyleSheetBase* SfxStyleSheetBasePool::Create
(
const XubString& rName,
Modified: incubator/ooo/trunk/main/sw/inc/docstyle.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/inc/docstyle.hxx?rev=1354011&r1=1354010&r2=1354011&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/inc/docstyle.hxx (original)
+++ incubator/ooo/trunk/main/sw/inc/docstyle.hxx Tue Jun 26 13:36:31 2012
@@ -219,9 +219,6 @@ public:
void SetOrganizerMode( sal_Bool bMode ) { bOrganizer = bMode; }
sal_Bool IsOrganizerMode() const { return bOrganizer; }
- virtual SfxStyleSheetIterator* CreateIterator( SfxStyleFamily,
- sal_uInt16 nMask );
-
SwDoc& GetDoc() const { return rDoc; }
void dispose();
Modified: incubator/ooo/trunk/main/sw/source/core/unocore/unostyle.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/source/core/unocore/unostyle.cxx?rev=1354011&r1=1354010&r2=1354011&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/source/core/unocore/unostyle.cxx (original)
+++ incubator/ooo/trunk/main/sw/source/core/unocore/unostyle.cxx Tue Jun 26 13:36:31 2012
@@ -860,17 +860,16 @@ uno::Sequence< OUString > SwXStyleFamily
uno::Sequence< OUString > aRet;
if(pBasePool)
{
- SfxStyleSheetIterator* pIterator = pBasePool->CreateIterator(eFamily, 0xffff);
- sal_uInt16 nCount = pIterator->Count();
+ SfxStyleSheetIterator aIterator(pBasePool, eFamily, 0xffff);
+ sal_uInt16 nCount = aIterator.Count();
aRet.realloc(nCount);
OUString* pArray = aRet.getArray();
String aString;
for(sal_uInt16 i = 0; i < nCount; i++)
{
- SwStyleNameMapper::FillProgName((*pIterator)[i]->GetName(), aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True );
+ SwStyleNameMapper::FillProgName(aIterator[i]->GetName(), aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True );
pArray[i] = OUString ( aString );
}
- delete pIterator;
}
else
throw uno::RuntimeException();
Modified: incubator/ooo/trunk/main/sw/source/ui/app/docstyle.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/source/ui/app/docstyle.cxx?rev=1354011&r1=1354010&r2=1354011&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/source/ui/app/docstyle.cxx (original)
+++ incubator/ooo/trunk/main/sw/source/ui/app/docstyle.cxx Tue Jun 26 13:36:31 2012
@@ -2230,12 +2230,6 @@ void SwDocStyleSheetPool::Replace( SfxS
}
}
-SfxStyleSheetIterator* SwDocStyleSheetPool::CreateIterator(
- SfxStyleFamily eFam, sal_uInt16 _nMask )
-{
- return new SwStyleSheetIterator( this, eFam, _nMask );
-}
-
void SwDocStyleSheetPool::dispose()
{
mxStyleSheet.clear();