summaryrefslogtreecommitdiff
path: root/sw/source/filter/basflt/iodetect.cxx
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-03-11 06:43:06 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-03-11 06:38:15 +0000
commite94d5233dd7939c54eb52fff456e817cecdf0a4c (patch)
tree24acd3465e88b1a2a26246272a41236edfbe9b21 /sw/source/filter/basflt/iodetect.cxx
parentfb827f2a342602f7e62dbdebb638326193315eb6 (diff)
work on sane lifecylce for SfxFilter
all SfxFilter instances should now be hold inside of a std::shared_ptr. This fixes a number of huge memory leaks in the test framework and removes one huge source of memory issue in sfx2. SfxMedium contains a pointer to the SfxFilter but does not own. Therefore it is required that any SfxFilter belonging to a SfxMedium lives longer. However this seems to work mostly by hoping that all SfxFilter instances are stored in a global array. As we have seen with the tests this is not true (there are also some cases inside of sd that seem to not follow that pattern as well). Change-Id: I12fd04a504cc4efc0a94967abd91c6fe2c6a8ce8 Reviewed-on: https://gerrit.libreoffice.org/23140 Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com> Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'sw/source/filter/basflt/iodetect.cxx')
-rw-r--r--sw/source/filter/basflt/iodetect.cxx10
1 files changed, 5 insertions, 5 deletions
diff --git a/sw/source/filter/basflt/iodetect.cxx b/sw/source/filter/basflt/iodetect.cxx
index ac2752d8adfc..2ac92f7c8a62 100644
--- a/sw/source/filter/basflt/iodetect.cxx
+++ b/sw/source/filter/basflt/iodetect.cxx
@@ -60,7 +60,7 @@ const OUString SwIoSystem::GetSubStorageName( const SfxFilter& rFltr )
return OUString();
}
-const SfxFilter* SwIoSystem::GetFilterOfFormat(const OUString& rFormatNm,
+std::shared_ptr<const SfxFilter> SwIoSystem::GetFilterOfFormat(const OUString& rFormatNm,
const SfxFilterContainer* pCnt)
{
SfxFilterContainer aCntSw( OUString(sSWRITER) );
@@ -72,7 +72,7 @@ const SfxFilter* SwIoSystem::GetFilterOfFormat(const OUString& rFormatNm,
{
SfxFilterMatcher aMatcher( pFltCnt->GetName() );
SfxFilterMatcherIter aIter( aMatcher );
- const SfxFilter* pFilter = aIter.First();
+ std::shared_ptr<const SfxFilter> pFilter = aIter.First();
while ( pFilter )
{
if( pFilter->GetUserData().equals(rFormatNm) )
@@ -141,7 +141,7 @@ bool SwIoSystem::IsValidStgFilter(SotStorage& rStg, const SfxFilter& rFilter)
// Check the type of the stream (file) by searching for corresponding set of bytes.
// If no known type is found, return ASCII for now!
// Returns the internal FilterName.
-const SfxFilter* SwIoSystem::GetFileFilter(const OUString& rFileName)
+std::shared_ptr<const SfxFilter> SwIoSystem::GetFileFilter(const OUString& rFileName)
{
SfxFilterContainer aCntSw( OUString(sSWRITER) );
SfxFilterContainer aCntSwWeb( OUString(sSWRITERWEB) );
@@ -149,7 +149,7 @@ const SfxFilter* SwIoSystem::GetFileFilter(const OUString& rFileName)
SfxFilterMatcher aMatcher( pFCntnr->GetName() );
SfxFilterMatcherIter aIter( aMatcher );
- const SfxFilter* pFilter = aIter.First();
+ std::shared_ptr<const SfxFilter> pFilter = aIter.First();
if ( !pFilter )
return nullptr;
@@ -163,7 +163,7 @@ const SfxFilter* SwIoSystem::GetFileFilter(const OUString& rFileName)
SfxMedium aMedium(aObj.GetMainURL(INetURLObject::NO_DECODE), STREAM_STD_READ);
// templates should not get precedence over "normal" filters (#i35508, #i33168)
- const SfxFilter* pTemplateFilter = nullptr;
+ std::shared_ptr<const SfxFilter> pTemplateFilter;
if (aMedium.IsStorage())
{
uno::Reference<embed::XStorage> const xStor = aMedium.GetStorage();