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

Miklos Vajna vmiklos at collabora.co.uk
Thu Oct 20 08:25:42 UTC 2016


 desktop/qa/desktop_lib/test_desktop_lib.cxx |   16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

New commits:
commit ef7ab996d8e4479b1944f7eaf506a506647a90dd
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Oct 20 08:14:07 2016 +0200

    CppunitTest_desktop_lib: fix valgrind errors
    
    With this, 'make -sr CppunitTest_desktop_lib
    CPPUNIT_TEST_NAME="DesktopLOKTest::testPaintPartTile
    DesktopLOKTest::testWriterCommentInsertCursor" VALGRIND=memcheck'
    finishes with 'ERROR SUMMARY: 0 errors from 0 contexts'.
    
    The problem is that in sw/sc/sd code it's enough to make sure that the
    on-stack ViewCallback instances are destroyed after the loaded
    component, but in desktop/ code also the emit-callbacks-on-idle code is
    under test, so we need to make sure first the LOK document wrapper is
    destroyed, and only after that the ViewCallback instances are destroyed.
    
    Change-Id: Ie8361233461d00fd252da929fb912a1a0b835c30
    Reviewed-on: https://gerrit.libreoffice.org/30072
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 1c92165..11c8db4 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -1541,16 +1541,17 @@ void DesktopLOKTest::testPaintPartTile()
 {
     // Load an impress doc of 2 slides.
     comphelper::LibreOfficeKit::setActive();
-    LibLODocument_Impl* pDocument = loadDoc("2slides.odp");
-    pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}");
     ViewCallback aView1;
+    ViewCallback aView2;
+    std::unique_ptr<LibLODocument_Impl> xDocument(loadDoc("2slides.odp"));
+    LibLODocument_Impl* pDocument = xDocument.get();
+    pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}");
     pDocument->m_pDocumentClass->registerCallback(pDocument, &ViewCallback::callback, &aView1);
     int nView1 = pDocument->m_pDocumentClass->getView(pDocument);
 
     // Create a second view.
     pDocument->m_pDocumentClass->createView(pDocument);
     pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}");
-    ViewCallback aView2;
     pDocument->m_pDocumentClass->registerCallback(pDocument, &ViewCallback::callback, &aView2);
 
     // Go to the second slide in the second view.
@@ -1578,7 +1579,6 @@ void DesktopLOKTest::testPaintPartTile()
     CPPUNIT_ASSERT(aView1.m_bTilesInvalidated);
 
     Scheduler::ProcessEventsToIdle();
-    mxComponent->dispose();
     mxComponent.clear();
     comphelper::LibreOfficeKit::setActive(false);
 }
@@ -1587,13 +1587,14 @@ void DesktopLOKTest::testWriterCommentInsertCursor()
 {
     // Load a document and type a character into the body text of the second view.
     comphelper::LibreOfficeKit::setActive();
-    LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
-    pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}");
     ViewCallback aView1;
+    ViewCallback aView2;
+    std::unique_ptr<LibLODocument_Impl> xDocument(loadDoc("blank_text.odt"));
+    LibLODocument_Impl* pDocument = xDocument.get();
+    pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}");
     pDocument->m_pDocumentClass->registerCallback(pDocument, &ViewCallback::callback, &aView1);
     pDocument->m_pDocumentClass->createView(pDocument);
     pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}");
-    ViewCallback aView2;
     pDocument->m_pDocumentClass->registerCallback(pDocument, &ViewCallback::callback, &aView2);
     pDocument->m_pDocumentClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 'x', 0);
     pDocument->m_pDocumentClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYUP, 'x', 0);
@@ -1618,7 +1619,6 @@ void DesktopLOKTest::testWriterCommentInsertCursor()
     CPPUNIT_ASSERT(aView1.m_aOwnCursor.IsEmpty());
 
     Scheduler::ProcessEventsToIdle();
-    mxComponent->dispose();
     mxComponent.clear();
     comphelper::LibreOfficeKit::setActive(false);
 }


More information about the Libreoffice-commits mailing list