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 /sw/source/uibase/app/docsh2.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 'sw/source/uibase/app/docsh2.cxx')
-rw-r--r-- | sw/source/uibase/app/docsh2.cxx | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/sw/source/uibase/app/docsh2.cxx b/sw/source/uibase/app/docsh2.cxx index 2127b1ed3531..80a03b7131d6 100644 --- a/sw/source/uibase/app/docsh2.cxx +++ b/sw/source/uibase/app/docsh2.cxx @@ -510,7 +510,7 @@ void SwDocShell::Execute(SfxRequest& rReq) SfxFilterMatcher aMatcher( OUString::createFromAscii(rFact.GetShortName()) ); SfxFilterMatcherIter aIter( aMatcher ); uno::Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY); - const SfxFilter* pFlt = aIter.First(); + std::shared_ptr<const SfxFilter> pFlt = aIter.First(); while( pFlt ) { // --> OD #i117339# @@ -524,7 +524,7 @@ void SwDocShell::Execute(SfxRequest& rReq) pFlt = aIter.Next(); } bool bWeb = dynamic_cast< SwWebDocShell *>( this ) != nullptr; - const SfxFilter *pOwnFlt = + std::shared_ptr<const SfxFilter> pOwnFlt = SwDocShell::Factory().GetFilterContainer()-> GetFilter4FilterName("writer8"); @@ -591,7 +591,7 @@ void SwDocShell::Execute(SfxRequest& rReq) // 1 - file unsaved -> save as HTML // 2 - file modified and HTML filter active -> save // 3 - file saved in non-HTML -> QueryBox to save as HTML - const SfxFilter* pHtmlFlt = + std::shared_ptr<const SfxFilter> pHtmlFlt = SwIoSystem::GetFilterOfFormat( "HTML", SwWebDocShell::Factory().GetFilterContainer() ); @@ -599,7 +599,7 @@ void SwDocShell::Execute(SfxRequest& rReq) if(bLocalHasName) { //check for filter type - const SfxFilter* pFlt = GetMedium()->GetFilter(); + std::shared_ptr<const SfxFilter> pFlt = GetMedium()->GetFilter(); if(!pFlt || pFlt->GetUserData() != pHtmlFlt->GetUserData()) { ScopedVclPtrInstance<MessageDialog> aQuery(&pViewFrame->GetWindow(), @@ -915,7 +915,7 @@ void SwDocShell::Execute(SfxRequest& rReq) aDlgHelper.SetControlHelpIds( nControlIds, pHelpIds ); uno::Reference < XFilePicker2 > xFP = aDlgHelper.GetFilePicker(); - const SfxFilter* pFlt; + std::shared_ptr<const SfxFilter> pFlt; sal_uInt16 nStrId; if( bCreateHtml ) @@ -1393,13 +1393,13 @@ sal_uLong SwDocShell::LoadStylesFromFile( const OUString& rURL, // search for filter in WebDocShell, too SfxMedium aMed( rURL, STREAM_STD_READ ); - const SfxFilter* pFlt = nullptr; - aMatcher.DetectFilter( aMed, &pFlt ); + std::shared_ptr<const SfxFilter> pFlt; + aMatcher.DetectFilter( aMed, pFlt ); if(!pFlt) { OUString sWebFactory(OUString::createFromAscii(SwWebDocShell::Factory().GetShortName())); SfxFilterMatcher aWebMatcher( sWebFactory ); - aWebMatcher.DetectFilter( aMed, &pFlt ); + aWebMatcher.DetectFilter( aMed, pFlt ); } // --> OD #i117339# - trigger import only for own formats bool bImport( false ); @@ -1550,7 +1550,7 @@ int SwFindDocShell( SfxObjectShellRef& xDocSh, if( INetProtocol::File == aTmpObj.GetProtocol() ) xMed->Download(); // Touch the medium (download it) - const SfxFilter* pSfxFlt = nullptr; + std::shared_ptr<const SfxFilter> pSfxFlt; if (!xMed->GetError()) { SfxFilterMatcher aMatcher( OUString::createFromAscii(SwDocShell::Factory().GetShortName()) ); @@ -1568,7 +1568,7 @@ int SwFindDocShell( SfxObjectShellRef& xDocSh, xMed->GetItemSet()->Put( SfxStringItem( SID_PASSWORD, rPasswd )); if( !pSfxFlt ) - aMatcher.DetectFilter( *xMed, &pSfxFlt ); + aMatcher.DetectFilter( *xMed, pSfxFlt ); if( pSfxFlt ) { |