summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2020-06-10 11:08:36 +0200
committerTomaž Vajngerl <quikee@gmail.com>2020-06-10 15:58:16 +0200
commit8ca89dc44aa5905d8d189be765ad2a1a613d31f4 (patch)
tree00c40ccf3e3e8d89ee1cb21d4e7071acae33ef78 /sd
parent2a82ea5c04f76af330686cd31e68f6f0d628db74 (diff)
fix reseting WeakReference when moving a ref to another ref.
In ViewIteratorImpl::Reverse we std::move a reference, to a local variable, however the reference was not reset correctly, which caused a crash. The issue is that a mpWeakConnection in WeakReference always needs to be non-null as shown in reset(reference_type* pReference) method. In the move constructor of WeakReference, we just std::move the reference like: mpWeakConnection = std::move(rWeakRef.mpWeakConnection); This means rWeakRef.mpWeakConnection will be reset to null, which is not what is expected, so what is missing is to instantiate rWeakRef.mpWeakConnection by calling reset(nullptr) or using the added reset() method. This also adds a test for LOKit PDF search as this is the case where the crash has been reproduced. It happens because of a call to: ... std::move(maPosition.mxObject); in the method ViewIteratorImpl::Reverse() Change-Id: I43692554ba4f6231d00091269b7c902ab5cbc11f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95995 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sd')
-rw-r--r--sd/qa/unit/tiledrendering/LOKitSearchTest.cxx39
-rw-r--r--sd/qa/unit/tiledrendering/data/OnePDFObject.odgbin0 -> 124632 bytes
2 files changed, 39 insertions, 0 deletions
diff --git a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
index 91b5ecbc8473..ac2695441575 100644
--- a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
+++ b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
@@ -57,6 +57,7 @@ public:
void testDontSearchInMasterPages();
void testSearchInPDFNonExisting();
void testSearchInPDF();
+ void testSearchInPDFOnePDFObject();
void testSearchInPDFInMultiplePages();
void testSearchInPDFInMultiplePagesBackwards();
void testSearchIn2MixedObjects();
@@ -71,6 +72,7 @@ public:
CPPUNIT_TEST(testDontSearchInMasterPages);
CPPUNIT_TEST(testSearchInPDFNonExisting);
CPPUNIT_TEST(testSearchInPDF);
+ CPPUNIT_TEST(testSearchInPDFOnePDFObject);
CPPUNIT_TEST(testSearchInPDFInMultiplePages);
CPPUNIT_TEST(testSearchInPDFInMultiplePagesBackwards);
CPPUNIT_TEST(testSearchIn2MixedObjects);
@@ -342,6 +344,43 @@ void LOKitSearchTest::testSearchInPDF()
#endif
}
+void LOKitSearchTest::testSearchInPDFOnePDFObject()
+{
+#if HAVE_FEATURE_PDFIUM
+ SdXImpressDocument* pXImpressDocument = createDoc("OnePDFObject.odg");
+ sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
+ CPPUNIT_ASSERT(pViewShell);
+ mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
+
+ SdPage* pPage = pViewShell->GetActualPage();
+ CPPUNIT_ASSERT(pPage);
+
+ SdrObject* pObject = pPage->GetObj(0);
+ CPPUNIT_ASSERT(pObject);
+
+ SdrGrafObj* pGraphicObject = dynamic_cast<SdrGrafObj*>(pObject);
+ CPPUNIT_ASSERT(pGraphicObject);
+
+ Graphic aGraphic = pGraphicObject->GetGraphic();
+ auto const& pVectorGraphicData = aGraphic.getVectorGraphicData();
+ CPPUNIT_ASSERT(pVectorGraphicData);
+ CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
+ pVectorGraphicData->getVectorGraphicDataType());
+
+ // Search down
+ lcl_search("ABC", false, false);
+
+ CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
+ CPPUNIT_ASSERT_EQUAL(1, mpCallbackRecorder->m_nSearchResultCount);
+
+ // Search up
+ lcl_search("ABC", false, true); // This caused a crash
+
+ CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
+ CPPUNIT_ASSERT_EQUAL(2, mpCallbackRecorder->m_nSearchResultCount);
+#endif
+}
+
void LOKitSearchTest::testSearchInPDFInMultiplePages()
{
#if HAVE_FEATURE_PDFIUM
diff --git a/sd/qa/unit/tiledrendering/data/OnePDFObject.odg b/sd/qa/unit/tiledrendering/data/OnePDFObject.odg
new file mode 100644
index 000000000000..225741c7b50b
--- /dev/null
+++ b/sd/qa/unit/tiledrendering/data/OnePDFObject.odg
Binary files differ