summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmin Le Grand <alg@apache.org>2012-06-26 12:36:31 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-04-10 20:17:30 +0100
commit858c6610f3476bb47bb7b4e621a7ac48a9e34a75 (patch)
tree8eb898f314aa3c3099b6b2359a2bf8c52e1651dd
parenta6f169433ada74a81b2e3421ea9c68a36c821fbb (diff)
Resolves: #i120077# Memory leak fixed in ScXMLFontAutoStylePool_Impl
also checked and fixed memory leaks caused by not deleting SfxStyleSheetIterator instances. Found by: Chao Huang Patch by: Chao Huang Review by: alg (cherry picked from commit aee8221b3fbe64d8e88aa3a1b630214807cd86f0) Conflicts: sc/source/core/data/stlsheet.cxx sc/source/filter/xml/xmlfonte.cxx sfx2/source/doc/objcont.cxx svl/source/items/style.cxx sw/source/core/unocore/unostyle.cxx Resolves: #120077# ALG: Reverted r1354011, adapted all usages of SfxStyleSheetIterator and CreateIterator to use boost::shared_ptr (cherry picked from commit ec1819f218b94bed1556653e1b2b816a65da61ef) Conflicts: sc/source/core/data/stlsheet.cxx sc/source/filter/xml/xmlfonte.cxx sfx2/source/doc/objcont.cxx svl/inc/svl/style.hxx svl/source/items/style.cxx sw/source/core/unocore/unoframe.cxx sw/source/core/unocore/unostyle.cxx 26937d4d65562b14de0aea59a7b01cc4334f73c1 Change-Id: If99bf3ee399292ec269d68b36ee78ed63f033215
-rw-r--r--sc/source/core/data/patattr.cxx5
-rw-r--r--sc/source/core/data/stlsheet.cxx2
-rw-r--r--sc/source/filter/xml/xmlfonte.cxx8
-rw-r--r--sfx2/source/doc/objcont.cxx2
-rw-r--r--svl/inc/svl/style.hxx5
-rw-r--r--svl/source/items/style.cxx20
-rw-r--r--sw/inc/docstyle.hxx3
-rw-r--r--sw/source/core/unocore/unostyle.cxx3
-rw-r--r--sw/source/ui/app/docstyle.cxx5
9 files changed, 25 insertions, 28 deletions
diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx
index a391ad136831..af1d5c9e6f8d 100644
--- a/sc/source/core/data/patattr.cxx
+++ b/sc/source/core/data/patattr.cxx
@@ -1161,9 +1161,8 @@ void ScPatternAttr::UpdateStyleSheet()
//! 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();
+ SfxStyleSheetIteratorPtr pIter = pDoc->GetStyleSheetPool()->CreateIterator( SFX_STYLE_FAMILY_PARA, SFXSTYLEBIT_ALL );
+ pStyle = dynamic_cast< ScStyleSheet* >(pIter->First());
}
if (pStyle)
diff --git a/sc/source/core/data/stlsheet.cxx b/sc/source/core/data/stlsheet.cxx
index 3ef1b42b9c76..eaa692a798cc 100644
--- a/sc/source/core/data/stlsheet.cxx
+++ b/sc/source/core/data/stlsheet.cxx
@@ -109,7 +109,7 @@ bool ScStyleSheet::SetParent( const String& rParentName )
SfxStyleSheetBase* pStyle = pPool->Find( aEffName, nFamily );
if (!pStyle)
{
- SfxStyleSheetIterator* pIter = pPool->CreateIterator( nFamily, SFXSTYLEBIT_ALL );
+ SfxStyleSheetIteratorPtr pIter = pPool->CreateIterator( nFamily, SFXSTYLEBIT_ALL );
pStyle = pIter->First();
if (pStyle)
aEffName = pStyle->GetName();
diff --git a/sc/source/filter/xml/xmlfonte.cxx b/sc/source/filter/xml/xmlfonte.cxx
index 4092bfa18dfd..9b0c263c7c3f 100644
--- a/sc/source/filter/xml/xmlfonte.cxx
+++ b/sc/source/filter/xml/xmlfonte.cxx
@@ -82,7 +82,13 @@ ScXMLFontAutoStylePool_Impl::ScXMLFontAutoStylePool_Impl(
const SfxItemPool* pEditPool(rExportP.GetDocument()->GetEditPool());
AddFontItems(aEditWhichIds, 3, pEditPool, false);
- SfxStyleSheetIterator* pItr(rExportP.GetDocument() ? rExportP.GetDocument()->GetStyleSheetPool()->CreateIterator(SFX_STYLE_FAMILY_PAGE, 0xFFFF) : NULL);
+ SfxStyleSheetIteratorPtr pItr;
+
+ if(rExportP.GetDocument())
+ {
+ pItr = rExportP.GetDocument()->GetStyleSheetPool()->CreateIterator(SFX_STYLE_FAMILY_PAGE, 0xFFFF);
+ }
+
if(pItr)
{
SfxStyleSheetBase* pStyle(pItr->First());
diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx
index a03879c4ddbe..7f3a31e5213a 100644
--- a/sfx2/source/doc/objcont.cxx
+++ b/sfx2/source/doc/objcont.cxx
@@ -600,8 +600,6 @@ sal_Bool SfxObjectShell::Remove
return bRet;
}
-//--------------------------------------------------------------------
-
void SfxObjectShell::LoadStyles
(
SfxObjectShell &rSource /* the document template from which
diff --git a/svl/inc/svl/style.hxx b/svl/inc/svl/style.hxx
index 664ca5cb1ec2..af58cbc44327 100644
--- a/svl/inc/svl/style.hxx
+++ b/svl/inc/svl/style.hxx
@@ -37,10 +37,10 @@
#include <svl/stylesheetuser.hxx>
#include <svl/style.hrc>
+#include <boost/shared_ptr.hpp>
class SfxItemSet;
class SfxItemPool;
-
class SfxStyleSheetBasePool;
class SvStream;
@@ -192,6 +192,7 @@ private:
friend class SfxStyleSheetBasePool;
};
+typedef ::boost::shared_ptr< SfxStyleSheetIterator > SfxStyleSheetIteratorPtr;
//=========================================================================
class SfxStyleSheetBasePool_Impl;
@@ -228,7 +229,7 @@ public:
SfxItemPool& GetPool();
const SfxItemPool& GetPool() const;
- virtual SfxStyleSheetIterator* CreateIterator(SfxStyleFamily, sal_uInt16 nMask);
+ virtual SfxStyleSheetIteratorPtr CreateIterator(SfxStyleFamily, sal_uInt16 nMask);
virtual sal_uInt16 Count();
virtual SfxStyleSheetBase* operator[](sal_uInt16 nIdx);
diff --git a/svl/source/items/style.cxx b/svl/source/items/style.cxx
index cd44bea2bbb7..c2879e799f1a 100644
--- a/svl/source/items/style.cxx
+++ b/svl/source/items/style.cxx
@@ -83,10 +83,8 @@ SfxStyleSheetHint::SfxStyleSheetHint
class SfxStyleSheetBasePool_Impl
{
- public:
- SfxStyleSheetIterator *pIter;
- SfxStyleSheetBasePool_Impl() : pIter(0){}
- ~SfxStyleSheetBasePool_Impl(){delete pIter;}
+public:
+ SfxStyleSheetIteratorPtr pIter;
};
@@ -532,13 +530,12 @@ void SfxStyleSheetBasePool::Replace(
SfxStyleSheetIterator& SfxStyleSheetBasePool::GetIterator_Impl()
{
- SfxStyleSheetIterator*& rpIter = pImp->pIter;
- if( !rpIter || (rpIter->GetSearchMask() != nMask) || (rpIter->GetSearchFamily() != nSearchFamily) )
+ if( !pImp->pIter || (pImp->pIter->GetSearchMask() != nMask) || (pImp->pIter->GetSearchFamily() != nSearchFamily) )
{
- delete rpIter;
- rpIter = CreateIterator( nSearchFamily, nMask );
+ pImp->pIter = CreateIterator( nSearchFamily, nMask );
}
- return *rpIter;
+
+ return *pImp->pIter;
}
SfxStyleSheetBasePool::SfxStyleSheetBasePool( SfxItemPool& r )
@@ -603,14 +600,13 @@ sal_uInt16 SfxStyleSheetBasePool::GetSearchMask() const
return nMask;
}
-
-SfxStyleSheetIterator* SfxStyleSheetBasePool::CreateIterator
+SfxStyleSheetIteratorPtr SfxStyleSheetBasePool::CreateIterator
(
SfxStyleFamily eFam,
sal_uInt16 mask
)
{
- return new SfxStyleSheetIterator(this,eFam,mask);
+ return SfxStyleSheetIteratorPtr(new SfxStyleSheetIterator(this,eFam,mask));
}
SfxStyleSheetBase* SfxStyleSheetBasePool::Create
diff --git a/sw/inc/docstyle.hxx b/sw/inc/docstyle.hxx
index 72ea158d3172..90a049e1ac88 100644
--- a/sw/inc/docstyle.hxx
+++ b/sw/inc/docstyle.hxx
@@ -208,8 +208,7 @@ public:
void SetOrganizerMode( sal_Bool bMode ) { bOrganizer = bMode; }
sal_Bool IsOrganizerMode() const { return bOrganizer; }
- virtual SfxStyleSheetIterator* CreateIterator( SfxStyleFamily,
- sal_uInt16 nMask );
+ virtual SfxStyleSheetIteratorPtr CreateIterator( SfxStyleFamily, sal_uInt16 nMask );
SwDoc& GetDoc() const { return rDoc; }
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index 49502e0cdc9f..a7d3b1764680 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -785,7 +785,7 @@ uno::Sequence< OUString > SwXStyleFamily::getElementNames(void) throw( uno::Runt
uno::Sequence< OUString > aRet;
if(pBasePool)
{
- SfxStyleSheetIterator* pIterator = pBasePool->CreateIterator(eFamily, SFXSTYLEBIT_ALL);
+ SfxStyleSheetIteratorPtr pIterator = pBasePool->CreateIterator(eFamily, SFXSTYLEBIT_ALL);
sal_uInt16 nCount = pIterator->Count();
aRet.realloc(nCount);
OUString* pArray = aRet.getArray();
@@ -795,7 +795,6 @@ uno::Sequence< OUString > SwXStyleFamily::getElementNames(void) throw( uno::Runt
SwStyleNameMapper::FillProgName((*pIterator)[i]->GetName(), aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), true );
pArray[i] = OUString ( aString );
}
- delete pIterator;
}
else
throw uno::RuntimeException();
diff --git a/sw/source/ui/app/docstyle.cxx b/sw/source/ui/app/docstyle.cxx
index 2af3322ea944..934f7174b47b 100644
--- a/sw/source/ui/app/docstyle.cxx
+++ b/sw/source/ui/app/docstyle.cxx
@@ -2179,10 +2179,9 @@ void SwDocStyleSheetPool::Replace( SfxStyleSheetBase& rSource,
}
}
-SfxStyleSheetIterator* SwDocStyleSheetPool::CreateIterator(
- SfxStyleFamily eFam, sal_uInt16 _nMask )
+SfxStyleSheetIteratorPtr SwDocStyleSheetPool::CreateIterator( SfxStyleFamily eFam, sal_uInt16 _nMask )
{
- return new SwStyleSheetIterator( this, eFam, _nMask );
+ return SfxStyleSheetIteratorPtr(new SwStyleSheetIterator( this, eFam, _nMask ));
}
void SwDocStyleSheetPool::dispose()