diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2016-03-11 06:43:06 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2016-03-11 06:38:15 +0000 |
commit | e94d5233dd7939c54eb52fff456e817cecdf0a4c (patch) | |
tree | 24acd3465e88b1a2a26246272a41236edfbe9b21 /sfx2/source/doc/docfilt.cxx | |
parent | fb827f2a342602f7e62dbdebb638326193315eb6 (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 'sfx2/source/doc/docfilt.cxx')
-rw-r--r-- | sfx2/source/doc/docfilt.cxx | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/sfx2/source/doc/docfilt.cxx b/sfx2/source/doc/docfilt.cxx index ac457c07381b..061cf8f3d289 100644 --- a/sfx2/source/doc/docfilt.cxx +++ b/sfx2/source/doc/docfilt.cxx @@ -122,17 +122,17 @@ OUString SfxFilter::GetSuffixes() const return aRet; } -const SfxFilter* SfxFilter::GetDefaultFilter( const OUString& rName ) +std::shared_ptr<const SfxFilter> SfxFilter::GetDefaultFilter( const OUString& rName ) { return SfxFilterContainer::GetDefaultFilter_Impl( rName ); } -const SfxFilter* SfxFilter::GetDefaultFilterFromFactory( const OUString& rFact ) +std::shared_ptr<const SfxFilter> SfxFilter::GetDefaultFilterFromFactory( const OUString& rFact ) { return GetDefaultFilter( SfxObjectShell::GetServiceNameFromFactory( rFact ) ); } -const SfxFilter* SfxFilter::GetFilterByName( const OUString& rName ) +std::shared_ptr<const SfxFilter> SfxFilter::GetFilterByName( const OUString& rName ) { SfxFilterMatcher aMatch; return aMatch.GetFilter4FilterName( rName, SfxFilterFlags::NONE, SfxFilterFlags::NONE ); @@ -169,7 +169,7 @@ OUString SfxFilter::GetTypeFromStorage( const SotStorage& rStg ) SotClipboardFormatId nClipId = ((SotStorage&)rStg).GetFormat(); if ( nClipId != SotClipboardFormatId::NONE ) { - const SfxFilter* pFilter = SfxFilterMatcher().GetFilter4ClipBoardId( nClipId ); + std::shared_ptr<const SfxFilter> pFilter = SfxFilterMatcher().GetFilter4ClipBoardId( nClipId ); if ( pFilter ) return pFilter->GetTypeName(); } @@ -206,7 +206,7 @@ OUString SfxFilter::GetTypeFromStorage( nDont |= SfxFilterFlags::TEMPLATEPATH; // get filter from storage MediaType - const SfxFilter* pFilter = aMatcher.GetFilter4ClipBoardId( nClipId, nMust, nDont ); + std::shared_ptr<const SfxFilter> pFilter = aMatcher.GetFilter4ClipBoardId( nClipId, nMust, nDont ); if ( !pFilter ) // template filter is asked for , but there isn't one; so at least the "normal" format should be detected // or storage *is* a template, but bTemplate is not set |