From ef7ab996d8e4479b1944f7eaf506a506647a90dd Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 20 Oct 2016 08:14:07 +0200 Subject: 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 Tested-by: Jenkins --- desktop/qa/desktop_lib/test_desktop_lib.cxx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 1c92165bf25b..11c8db46ebc5 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 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 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); } -- cgit