diff options
author | Jan Holesovsky <kendy@collabora.com> | 2017-03-20 23:05:22 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2017-03-21 10:51:58 +0000 |
commit | 89f5bb3cbbddd0b7b815ddd96f25500a9ff78e8b (patch) | |
tree | 3afc7398086973a3e2404259bfb81aeabdce674c /libreofficekit/qa/unit | |
parent | b6e62dc0dc2b284c825f1182a67bb2f9259a30ce (diff) |
lok: Fix crash in paintPartTile() when the current view was destroyed.
Change-Id: I59b71ee6815cbcfa4c8b5f68ae6dc9299856d49e
Reviewed-on: https://gerrit.libreoffice.org/35494
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Diffstat (limited to 'libreofficekit/qa/unit')
-rw-r--r-- | libreofficekit/qa/unit/tiledrendering.cxx | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/libreofficekit/qa/unit/tiledrendering.cxx b/libreofficekit/qa/unit/tiledrendering.cxx index 5987d14e566a..70d7a4ae814b 100644 --- a/libreofficekit/qa/unit/tiledrendering.cxx +++ b/libreofficekit/qa/unit/tiledrendering.cxx @@ -72,6 +72,7 @@ public: void testDocumentTypes( Office* pOffice ); void testImpressSlideNames( Office* pOffice ); void testCalcSheetNames( Office* pOffice ); + void testPaintPartTile( Office* pOffice ); #if 0 void testOverlay( Office* pOffice ); #endif @@ -98,6 +99,7 @@ void TiledRenderingTest::runAllTests() testDocumentTypes( pOffice.get() ); testImpressSlideNames( pOffice.get() ); testCalcSheetNames( pOffice.get() ); + testPaintPartTile( pOffice.get() ); #if 0 testOverlay( pOffice.get() ); #endif @@ -186,6 +188,36 @@ void TiledRenderingTest::testCalcSheetNames( Office* pOffice ) CPPUNIT_ASSERT_EQUAL(std::string("Sheet3"), std::string(pDocument->getPartName(2))); } +void TiledRenderingTest::testPaintPartTile(Office* pOffice) +{ + const string sTextDocPath = m_sSrcRoot + "/libreofficekit/qa/data/blank_text.odt"; + const string sTextLockFile = m_sSrcRoot +"/libreofficekit/qa/data/.~lock.blank_text.odt#"; + + // FIXME: same comment as below wrt lockfile removal. + remove(sTextLockFile.c_str()); + + std::unique_ptr<Document> pDocument(pOffice->documentLoad( sTextDocPath.c_str())); + CPPUNIT_ASSERT(pDocument.get()); + CPPUNIT_ASSERT_EQUAL(LOK_DOCTYPE_TEXT, static_cast<LibreOfficeKitDocumentType>(pDocument->getDocumentType())); + + // Create two views. + pDocument->getView(); + pDocument->createView(); + + int nView2 = pDocument->getView(); + + // Destroy the current view + pDocument->destroyView(nView2); + + int nCanvasWidth = 256; + int nCanvasHeight = 256; + std::vector<unsigned char> aBuffer(nCanvasWidth * nCanvasHeight * 4); + + // And try to paintPartTile() - this used to crash when the current viewId + // was destroyed + pDocument->paintPartTile(aBuffer.data(), /*nPart=*/0, nCanvasWidth, nCanvasHeight, /*nTilePosX=*/0, /*nTilePosY=*/0, /*nTileWidth=*/3840, /*nTileHeight=*/3840); +} + #if 0 static void dumpRGBABitmap( const OUString& rPath, const unsigned char* pBuffer, const int nWidth, const int nHeight ) |