From 4df6475ffe0d1c1b0acb6b8c02c9da6f388d3387 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 19 Jun 2017 09:21:10 +0100 Subject: ofz: leaks in test harness Change-Id: I2bcbf84dff8a5f6a2311cd0b1f19e90c03e6175c --- sw/source/filter/ww8/ww8par.cxx | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'sw') diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index 1ce758822888..30cf48d92935 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -6170,12 +6170,22 @@ extern "C" SAL_DLLPUBLIC_EXPORT Reader* SAL_CALL ImportDOC() return new WW8Reader; } +class FontCacheGuard +{ +public: + ~FontCacheGuard() + { + FlushFontCache(); + } +}; + bool SAL_CALL TestImportDOC(SvStream &rStream, const OUString &rFltName) { - Reader *pReader = ImportDOC(); + FontCacheGuard aFontCacheGuard; + std::unique_ptr xReader(ImportDOC()); tools::SvRef xStorage; - pReader->pStrm = &rStream; + xReader->pStrm = &rStream; if (rFltName != "WW6") { try @@ -6188,9 +6198,9 @@ bool SAL_CALL TestImportDOC(SvStream &rStream, const OUString &rFltName) { return false; } - pReader->pStg = xStorage.get(); + xReader->pStg = xStorage.get(); } - pReader->SetFltName(rFltName); + xReader->SetFltName(rFltName); SwGlobals::ensure(); @@ -6207,11 +6217,8 @@ bool SAL_CALL TestImportDOC(SvStream &rStream, const OUString &rFltName) SwPaM aPaM( aIdx ); aPaM.GetPoint()->nContent.Assign(aIdx.GetNode().GetContentNode(), 0); pD->SetInReading(true); - bool bRet = pReader->Read(*pD, OUString(), aPaM, OUString()) == 0; + bool bRet = xReader->Read(*pD, OUString(), aPaM, OUString()) == 0; pD->SetInReading(false); - delete pReader; - - FlushFontCache(); return bRet; } -- cgit