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/dochdl | |
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/dochdl')
-rw-r--r-- | sw/source/uibase/dochdl/gloshdl.cxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/dochdl/swdtflvr.cxx | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/sw/source/uibase/dochdl/gloshdl.cxx b/sw/source/uibase/dochdl/gloshdl.cxx index 159ef0c60c1f..581189b35aee 100644 --- a/sw/source/uibase/dochdl/gloshdl.cxx +++ b/sw/source/uibase/dochdl/gloshdl.cxx @@ -710,11 +710,11 @@ bool SwGlossaryHdl::ImportGlossaries( const OUString& rName ) bool bRet = false; if( !rName.isEmpty() ) { - const SfxFilter* pFilter = nullptr; + std::shared_ptr<const SfxFilter> pFilter; std::unique_ptr<SfxMedium> pMed(new SfxMedium( rName, StreamMode::READ, nullptr, nullptr )); SfxFilterMatcher aMatcher( OUString("swriter") ); pMed->UseInteractionHandler( true ); - if (!aMatcher.GuessFilter(*pMed, &pFilter, SfxFilterFlags::NONE)) + if (!aMatcher.GuessFilter(*pMed, pFilter, SfxFilterFlags::NONE)) { SwTextBlocks *pGlossary = nullptr; pMed->SetFilter( pFilter ); diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx index 5dc3dfd68b91..469080f4497a 100644 --- a/sw/source/uibase/dochdl/swdtflvr.cxx +++ b/sw/source/uibase/dochdl/swdtflvr.cxx @@ -2568,7 +2568,7 @@ bool SwTransferable::_PasteFileName( TransferableDataHelper& rData, //Own FileFormat? --> insert, not for StarWriter/Web OUString sFileURL = URIHelper::SmartRel2Abs(INetURLObject(), sFile, Link<OUString *, bool>(), false ); - const SfxFilter* pFlt = SwPasteSdr::SetAttr == nAction + std::shared_ptr<const SfxFilter> pFlt = SwPasteSdr::SetAttr == nAction ? nullptr : SwIoSystem::GetFileFilter(sFileURL); if( pFlt && dynamic_cast< const SwWebDocShell *>( rSh.GetView().GetDocShell() ) == nullptr ) { |