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 /desktop | |
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 'desktop')
-rw-r--r-- | desktop/source/app/dispatchwatcher.cxx | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/desktop/source/app/dispatchwatcher.cxx b/desktop/source/app/dispatchwatcher.cxx index 49dce8122441..3ba4e152c29a 100644 --- a/desktop/source/app/dispatchwatcher.cxx +++ b/desktop/source/app/dispatchwatcher.cxx @@ -88,7 +88,7 @@ struct DispatchHolder namespace { -const SfxFilter* impl_lookupExportFilterForUrl( const rtl::OUString& rUrl, const rtl::OUString& rFactory ) +std::shared_ptr<const SfxFilter> impl_lookupExportFilterForUrl( const rtl::OUString& rUrl, const rtl::OUString& rFactory ) { // create the list of filters OUStringBuffer sQuery(256); @@ -105,7 +105,7 @@ const SfxFilter* impl_lookupExportFilterForUrl( const rtl::OUString& rUrl, const xContext->getServiceManager()->createInstanceWithContext( "com.sun.star.document.FilterFactory", xContext ), UNO_QUERY_THROW ); - const SfxFilter* pBestMatch = nullptr; + std::shared_ptr<const SfxFilter> pBestMatch; const Reference< XEnumeration > xFilterEnum( xFilterFactory->createSubSetEnumerationByQuery( sQuery.makeStringAndClear() ), UNO_QUERY_THROW ); @@ -115,7 +115,7 @@ const SfxFilter* impl_lookupExportFilterForUrl( const rtl::OUString& rUrl, const const rtl::OUString aName( aFilterProps.getUnpackedValueOrDefault( "Name", rtl::OUString() ) ); if ( !aName.isEmpty() ) { - const SfxFilter* const pFilter( SfxFilter::GetFilterByName( aName ) ); + std::shared_ptr<const SfxFilter> pFilter( SfxFilter::GetFilterByName( aName ) ); if ( pFilter && pFilter->CanExport() && pFilter->GetWildcard().Matches( rUrl ) ) { if ( !pBestMatch || ( SfxFilterFlags::PREFERED & pFilter->GetFilterFlags() ) ) @@ -127,7 +127,7 @@ const SfxFilter* impl_lookupExportFilterForUrl( const rtl::OUString& rUrl, const return pBestMatch; } -static const SfxFilter* impl_getExportFilterFromUrl( +static std::shared_ptr<const SfxFilter> impl_getExportFilterFromUrl( const rtl::OUString& rUrl, const rtl::OUString& rFactory) { try @@ -138,7 +138,7 @@ try UNO_QUERY_THROW ); const rtl::OUString aTypeName( xTypeDetector->queryTypeByURL( rUrl ) ); - const SfxFilter* pFilter( SfxFilterMatcher( rFactory ).GetFilter4EA( aTypeName, SfxFilterFlags::EXPORT ) ); + std::shared_ptr<const SfxFilter> pFilter( SfxFilterMatcher( rFactory ).GetFilter4EA( aTypeName, SfxFilterFlags::EXPORT ) ); if ( !pFilter ) pFilter = impl_lookupExportFilterForUrl( rUrl, rFactory ); if ( !pFilter ) @@ -161,7 +161,7 @@ catch ( const Exception& ) OUString impl_GuessFilter( const OUString& rUrlOut, const OUString& rDocService ) { OUString aOutFilter; - const SfxFilter* pOutFilter = impl_getExportFilterFromUrl( rUrlOut, rDocService ); + std::shared_ptr<const SfxFilter> pOutFilter = impl_getExportFilterFromUrl( rUrlOut, rDocService ); if (pOutFilter) aOutFilter = pOutFilter->GetFilterName(); |