[Libreoffice-commits] core.git: sw/qa

Jochen Nitschke j.nitschke+logerrit at ok.de
Tue May 9 15:52:32 UTC 2017


 sw/qa/extras/uiwriter/uiwriter.cxx |   17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

New commits:
commit 67ab5337cd253671a241f1f045287c31986497b1
Author: Jochen Nitschke <j.nitschke+logerrit at ok.de>
Date:   Sun May 7 21:48:45 2017 +0200

    silence cppcheck memleak in unit test
    
    line 825: Memory leak 'pGlossary'
    
    Change-Id: Id7f103c4e6f8bd4b4941edfe815508305d9a5f55
    Reviewed-on: https://gerrit.libreoffice.org/37377
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Jochen Nitschke <j.nitschke+logerrit at ok.de>

diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 62958cfbac8e..57e41ebf5765 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -86,6 +86,7 @@
 #include "com/sun/star/text/TextMarkupType.hpp"
 #include <com/sun/star/chart2/data/XDataSource.hpp>
 #include <com/sun/star/document/XEmbeddedObjectSupplier2.hpp>
+#include <o3tl/make_unique.hxx>
 #include <osl/file.hxx>
 #include <paratr.hxx>
 #include <drawfont.hxx>
@@ -376,7 +377,7 @@ public:
 
 private:
     SwDoc* createDoc(const char* pName = nullptr);
-    SwTextBlocks* readDOCXAutotext(const OUString& sFileName, bool bEmpty = false);
+    std::unique_ptr<SwTextBlocks> readDOCXAutotext(const OUString& sFileName, bool bEmpty = false);
 };
 
 SwDoc* SwUiWriterTest::createDoc(const char* pName)
@@ -391,16 +392,16 @@ SwDoc* SwUiWriterTest::createDoc(const char* pName)
     return pTextDoc->GetDocShell()->GetDoc();
 }
 
-SwTextBlocks* SwUiWriterTest::readDOCXAutotext(const OUString& sFileName, bool bEmpty)
+std::unique_ptr<SwTextBlocks> SwUiWriterTest::readDOCXAutotext(const OUString& sFileName, bool bEmpty)
 {
     OUString rURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + sFileName;
 
-    SfxMedium* pSrcMed = new SfxMedium(rURL, StreamMode::STD_READ);
+    SfxMedium aSrcMed(rURL, StreamMode::STD_READ);
     SwDoc* pDoc = createDoc();
 
-    SwReader aReader(*pSrcMed, rURL, pDoc);
+    SwReader aReader(aSrcMed, rURL, pDoc);
     Reader* pDOCXReader = SwReaderWriter::GetDOCXReader();
-    SwTextBlocks* pGlossary = new SwTextBlocks(rURL);
+    auto pGlossary = o3tl::make_unique<SwTextBlocks>(rURL);
 
     CPPUNIT_ASSERT(pDOCXReader != nullptr);
     CPPUNIT_ASSERT_EQUAL(!bEmpty, aReader.ReadGlossaries(*pDOCXReader, *pGlossary, false));
@@ -772,14 +773,14 @@ void SwUiWriterTest::testExportRTF()
 void SwUiWriterTest::testDOCXAutoTextEmpty()
 {
     // file contains normal content but no AutoText
-    SwTextBlocks* pGlossary = readDOCXAutotext("autotext-empty.dotx", true);
+    std::unique_ptr<SwTextBlocks> pGlossary = readDOCXAutotext("autotext-empty.dotx", true);
     CPPUNIT_ASSERT(pGlossary != nullptr);
 }
 
 void SwUiWriterTest::testDOCXAutoTextMultiple()
 {
     // file contains three AutoText entries
-    SwTextBlocks* pGlossary = readDOCXAutotext("autotext-multiple.dotx");
+    std::unique_ptr<SwTextBlocks> pGlossary = readDOCXAutotext("autotext-multiple.dotx");
 
     // check entries count
     CPPUNIT_ASSERT_EQUAL((sal_uInt16)3, pGlossary->GetCount());
@@ -812,7 +813,7 @@ void SwUiWriterTest::testDOTMAutoText()
 {
     // this is dotm file difference is that in the dotm
     // there are no empty paragraphs at the end of each entry
-    SwTextBlocks* pGlossary = readDOCXAutotext("autotext-dotm.dotm");
+    std::unique_ptr<SwTextBlocks> pGlossary = readDOCXAutotext("autotext-dotm.dotm");
 
     SwDoc* pDoc = pGlossary->GetDoc();
     CPPUNIT_ASSERT(pDoc != nullptr);


More information about the Libreoffice-commits mailing list