[Libreoffice-commits] core.git: 4 commits - include/vcl sc/qa vcl/source

Markus Mohrhard markus.mohrhard at googlemail.com
Sun Mar 13 13:14:58 UTC 2016


 include/vcl/builder.hxx        |    2 -
 sc/qa/extras/sccondformats.cxx |   67 +++++++++++++++++------------------------
 vcl/source/gdi/impgraph.cxx    |    1 
 vcl/source/window/builder.cxx  |    2 -
 4 files changed, 32 insertions(+), 40 deletions(-)

New commits:
commit a4bd382c8a6cf5a79898c692752408477cd4cfc5
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sun Mar 13 11:54:57 2016 +0100

    add assert preventing memory leak
    
    Change-Id: I0c659bf4fab2319f06df09dd11a768a295e95722

diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index a8f1d0c..deb143e 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -943,6 +943,7 @@ sal_uLong ImpGraphic::ImplGetAnimationLoopCount() const
 
 void ImpGraphic::ImplSetContext( GraphicReader* pReader )
 {
+    assert(!mpContext);
     mpContext = pReader;
     mbDummyContext = false;
 }
commit d565391dffaddd302c1ec0735c96473dc33827bb
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sun Mar 13 11:53:06 2016 +0100

    this old concept was just a bad idea by me
    
    Change-Id: Ib13a7a252bdb3f54e520076666f98498c10b4d47

diff --git a/sc/qa/extras/sccondformats.cxx b/sc/qa/extras/sccondformats.cxx
index 8be88bb..49e6c20 100644
--- a/sc/qa/extras/sccondformats.cxx
+++ b/sc/qa/extras/sccondformats.cxx
@@ -29,8 +29,6 @@ using namespace css;
 
 namespace sc_apitest {
 
-#define NUMBER_OF_TESTS 1
-
 class ScConditionalFormatTest : public CalcUnoApiTest
 {
 public:
@@ -49,13 +47,9 @@ public:
     CPPUNIT_TEST_SUITE_END();
 private:
 
-    static sal_Int32 nTest;
-    static uno::Reference< lang::XComponent > mxComponent;
+    uno::Reference< lang::XComponent > mxComponent;
 };
 
-sal_Int32 ScConditionalFormatTest::nTest = 0;
-uno::Reference< lang::XComponent > ScConditionalFormatTest::mxComponent;
-
 ScConditionalFormatTest::ScConditionalFormatTest()
     : CalcUnoApiTest("sc/qa/unit/data/ods")
 {
@@ -223,16 +217,14 @@ void ScConditionalFormatTest::testUndoAnchor()
 
 void ScConditionalFormatTest::setUp()
 {
-    nTest++;
     CalcUnoApiTest::setUp();
 }
 
 void ScConditionalFormatTest::tearDown()
 {
-    if (nTest == NUMBER_OF_TESTS)
+    if (mxComponent.is())
     {
         closeDocument(mxComponent);
-        mxComponent.clear();
     }
 
     CalcUnoApiTest::tearDown();
commit 70b4de3257759057102b399a8e6bdbca4bff87b7
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sun Mar 13 11:52:24 2016 +0100

    no need for strange assert fail message
    
    Change-Id: Id982d0b12e18213a8d76a2d562109d7e2a41d8b5

diff --git a/sc/qa/extras/sccondformats.cxx b/sc/qa/extras/sccondformats.cxx
index 0ac865b..8be88bb 100644
--- a/sc/qa/extras/sccondformats.cxx
+++ b/sc/qa/extras/sccondformats.cxx
@@ -122,7 +122,6 @@ void ScConditionalFormatTest::testCondFormat()
 
 void ScConditionalFormatTest::testUndoAnchor()
 {
-    const OString sFailedMessage = OString("Failed on :");
     OUString aFileURL;
     createFileURL("document_with_linked_graphic.ods", aFileURL);
     // open the document with graphic included
@@ -134,48 +133,48 @@ void ScConditionalFormatTest::testUndoAnchor()
     CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell);
 
     ScDocShell* xDocSh = dynamic_cast<ScDocShell*>(pFoundShell);
-    CPPUNIT_ASSERT(xDocSh != nullptr);
+    CPPUNIT_ASSERT(xDocSh);
 
     // Check whether graphic imported well
     ScDocument& rDoc = xDocSh->GetDocument();
     ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer();
-    CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), pDrawLayer != nullptr );
+    CPPUNIT_ASSERT(pDrawLayer);
 
     const SdrPage *pPage = pDrawLayer->GetPage(0);
-    CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), pPage != nullptr );
+    CPPUNIT_ASSERT(pPage);
 
     SdrGrafObj* pObject = dynamic_cast<SdrGrafObj*>(pPage->GetObj(0));
-    CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), pObject != nullptr );
-    CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), pObject->IsLinkedGraphic() );
+    CPPUNIT_ASSERT(pObject);
+    CPPUNIT_ASSERT(pObject->IsLinkedGraphic());
 
     const GraphicObject& rGraphicObj = pObject->GetGraphicObject(true);
-    CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), !rGraphicObj.IsSwappedOut());
-    CPPUNIT_ASSERT_EQUAL_MESSAGE( sFailedMessage.getStr(), GRAPHIC_BITMAP, rGraphicObj.GetGraphic().GetType());
-    CPPUNIT_ASSERT_EQUAL_MESSAGE( sFailedMessage.getStr(), sal_uLong(864900), rGraphicObj.GetSizeBytes());
+    CPPUNIT_ASSERT(!rGraphicObj.IsSwappedOut());
+    CPPUNIT_ASSERT_EQUAL(GRAPHIC_BITMAP, rGraphicObj.GetGraphic().GetType());
+    CPPUNIT_ASSERT_EQUAL(sal_uLong(864900), rGraphicObj.GetSizeBytes());
 
     // Get the document controller
     ScTabViewShell* pViewShell = xDocSh->GetBestViewShell(false);
-    CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), pViewShell != nullptr );
+    CPPUNIT_ASSERT(pViewShell);
 
     // Get the draw view of the document
     ScDrawView* pDrawView = pViewShell->GetViewData().GetScDrawView();
-    CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), pDrawView != nullptr );
+    CPPUNIT_ASSERT(pDrawView);
 
     // Select graphic object
     pDrawView->MarkNextObj();
-    CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), pDrawView->AreObjectsMarked() );
+    CPPUNIT_ASSERT(pDrawView->AreObjectsMarked() );
 
     // Set Cell Anchor
     ScDrawLayer::SetCellAnchoredFromPosition(*pObject, rDoc, 0);
     // Check state
     ScAnchorType oldType = ScDrawLayer::GetAnchorType(*pObject);
-    CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), oldType == SCA_CELL );
+    CPPUNIT_ASSERT(oldType == SCA_CELL );
 
     // Change all selected objects to page anchor
     pViewShell->GetViewData().GetDispatcher().Execute(SID_ANCHOR_PAGE);
     // Check state
     ScAnchorType newType = ScDrawLayer::GetAnchorType(*pObject);
-    CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), newType == SCA_PAGE );
+    CPPUNIT_ASSERT(newType == SCA_PAGE );
 
     // Undo and check its result.
     SfxUndoManager* pUndoMgr = rDoc.GetUndoManager();
@@ -183,41 +182,41 @@ void ScConditionalFormatTest::testUndoAnchor()
     pUndoMgr->Undo();
 
     // Check anchor type
-    CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), oldType == ScDrawLayer::GetAnchorType(*pObject) );
-    CPPUNIT_ASSERT_EQUAL_MESSAGE( sFailedMessage.getStr(), GRAPHIC_BITMAP, rGraphicObj.GetGraphic().GetType());
-    CPPUNIT_ASSERT_EQUAL_MESSAGE( sFailedMessage.getStr(), sal_uLong(864900), rGraphicObj.GetSizeBytes());
+    CPPUNIT_ASSERT(oldType == ScDrawLayer::GetAnchorType(*pObject) );
+    CPPUNIT_ASSERT_EQUAL(GRAPHIC_BITMAP, rGraphicObj.GetGraphic().GetType());
+    CPPUNIT_ASSERT_EQUAL(sal_uLong(864900), rGraphicObj.GetSizeBytes());
 
     pUndoMgr->Redo();
 
     // Check anchor type
-    CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), newType == ScDrawLayer::GetAnchorType(*pObject) );
-    CPPUNIT_ASSERT_EQUAL_MESSAGE( sFailedMessage.getStr(), GRAPHIC_BITMAP, rGraphicObj.GetGraphic().GetType());
-    CPPUNIT_ASSERT_EQUAL_MESSAGE( sFailedMessage.getStr(), sal_uLong(864900), rGraphicObj.GetSizeBytes());
+    CPPUNIT_ASSERT(newType == ScDrawLayer::GetAnchorType(*pObject) );
+    CPPUNIT_ASSERT_EQUAL(GRAPHIC_BITMAP, rGraphicObj.GetGraphic().GetType());
+    CPPUNIT_ASSERT_EQUAL(sal_uLong(864900), rGraphicObj.GetSizeBytes());
 
     ScDrawLayer::SetPageAnchored(*pObject);
     // Check state
     oldType = ScDrawLayer::GetAnchorType(*pObject);
-    CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), oldType == SCA_PAGE );
+    CPPUNIT_ASSERT(oldType == SCA_PAGE );
 
     // Change all selected objects to cell anchor
     pViewShell->GetViewData().GetDispatcher().Execute(SID_ANCHOR_CELL);
     // Check state
     newType = ScDrawLayer::GetAnchorType(*pObject);
-    CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), newType == SCA_CELL );
+    CPPUNIT_ASSERT(newType == SCA_CELL );
 
     pUndoMgr->Undo();
 
     // Check anchor type
-    CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), oldType == ScDrawLayer::GetAnchorType(*pObject) );
-    CPPUNIT_ASSERT_EQUAL_MESSAGE( sFailedMessage.getStr(), GRAPHIC_BITMAP, rGraphicObj.GetGraphic().GetType());
-    CPPUNIT_ASSERT_EQUAL_MESSAGE( sFailedMessage.getStr(), sal_uLong(864900), rGraphicObj.GetSizeBytes());
+    CPPUNIT_ASSERT(oldType == ScDrawLayer::GetAnchorType(*pObject) );
+    CPPUNIT_ASSERT_EQUAL(GRAPHIC_BITMAP, rGraphicObj.GetGraphic().GetType());
+    CPPUNIT_ASSERT_EQUAL(sal_uLong(864900), rGraphicObj.GetSizeBytes());
 
     pUndoMgr->Redo();
 
     // Check anchor type
-    CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), newType == ScDrawLayer::GetAnchorType(*pObject) );
-    CPPUNIT_ASSERT_EQUAL_MESSAGE( sFailedMessage.getStr(), GRAPHIC_BITMAP, rGraphicObj.GetGraphic().GetType());
-    CPPUNIT_ASSERT_EQUAL_MESSAGE( sFailedMessage.getStr(), sal_uLong(864900), rGraphicObj.GetSizeBytes());
+    CPPUNIT_ASSERT(newType == ScDrawLayer::GetAnchorType(*pObject) );
+    CPPUNIT_ASSERT_EQUAL(GRAPHIC_BITMAP, rGraphicObj.GetGraphic().GetType());
+    CPPUNIT_ASSERT_EQUAL(sal_uLong(864900), rGraphicObj.GetSizeBytes());
 
     xComponent->dispose();
 }
commit 424966f0e967150ae51eaa886c12561cd7d3226e
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sun Mar 13 11:48:47 2016 +0100

    fix strange memory leak in VclBuilder
    
    Change-Id: Iba34c25b19a94a8d4c147f8ccaef95f34183414b

diff --git a/include/vcl/builder.hxx b/include/vcl/builder.hxx
index da6d091..a1db0f6 100644
--- a/include/vcl/builder.hxx
+++ b/include/vcl/builder.hxx
@@ -304,7 +304,7 @@ private:
     bool        m_bToplevelHasDeferredInit;
     bool        m_bToplevelHasDeferredProperties;
     bool        m_bToplevelParentFound;
-    ParserState *m_pParserState;
+    std::unique_ptr<ParserState> m_pParserState;
 
     vcl::Window *get_by_name(const OString& sID);
     void        delete_by_name(const OString& sID);
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index cc11c28..b55222b 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -484,7 +484,7 @@ VclBuilder::VclBuilder(vcl::Window *pParent, const OUString& sUIDir, const OUStr
     }
 
     //drop maps, etc. that we don't need again
-    delete m_pParserState;
+    m_pParserState.reset();
 
     SAL_WARN_IF(!m_sID.isEmpty() && (!m_bToplevelParentFound && !get_by_name(m_sID)), "vcl.layout",
         "Requested top level widget \"" << m_sID.getStr() <<


More information about the Libreoffice-commits mailing list