summaryrefslogtreecommitdiff
path: root/sc/qa
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2023-04-03 14:04:44 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-04-05 17:02:46 +0200
commite57d5daaea734ade43e8251120afa031099a0840 (patch)
tree671870d9d8338791682dd489564e5d8802b2cfa2 /sc/qa
parente4042da6e63ed2ac6e1687f696580d9a502bad83 (diff)
fix leaks when using tools::JsonWriter
Specifically in sd/source/core/annotations/Annotation.cxx We seem to end up fixing leaks here often. The current tools::JsonWriter API is just very hard to use correctly. So rather return an OString, which is cheap to copy, and push that down into the LOK code. AFAIK that seems to end up requiring less code and less adhoc copying of data (specifically the queueing code in init.cxx was creating copies when converting to std::string). Ideally, we could have some special API to avoid the new strdup() calls in init.cxx, but not sure how to prevent other people from accidentally using that. Change-Id: Ia33437c1bfd9cc2d54dfb99914d1b72db20335f2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149963 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc/qa')
-rw-r--r--sc/qa/unit/tiledrendering/tiledrendering.cxx14
1 files changed, 7 insertions, 7 deletions
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 9d5d129e4987..3e6accfe2c4b 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -1825,7 +1825,7 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testGetRowColumnHeadersInvalidation)
aView1.m_aInvalidations.clear();
tools::JsonWriter aJsonWriter1;
pModelObj->getRowColumnHeaders(tools::Rectangle(0, 15, 19650, 5400), aJsonWriter1);
- free(aJsonWriter1.extractData());
+ aJsonWriter1.finishAndGetAsOString();
Scheduler::ProcessEventsToIdle();
CPPUNIT_ASSERT(aView1.m_bInvalidateTiles);
CPPUNIT_ASSERT_EQUAL(size_t(1), aView1.m_aInvalidations.size());
@@ -1836,7 +1836,7 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testGetRowColumnHeadersInvalidation)
aView1.m_aInvalidations.clear();
tools::JsonWriter aJsonWriter2;
pModelObj->getRowColumnHeaders(tools::Rectangle(0, 5400, 19650, 9800), aJsonWriter2);
- free(aJsonWriter2.extractData());
+ aJsonWriter2.finishAndGetAsOString();
Scheduler::ProcessEventsToIdle();
CPPUNIT_ASSERT(aView1.m_bInvalidateTiles);
CPPUNIT_ASSERT_EQUAL(size_t(1), aView1.m_aInvalidations.size());
@@ -1847,7 +1847,7 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testGetRowColumnHeadersInvalidation)
aView1.m_aInvalidations.clear();
tools::JsonWriter aJsonWriter3;
pModelObj->getRowColumnHeaders(tools::Rectangle(5400, 5400, 25050, 9800), aJsonWriter3);
- free(aJsonWriter3.extractData());
+ aJsonWriter3.finishAndGetAsOString();
Scheduler::ProcessEventsToIdle();
CPPUNIT_ASSERT(aView1.m_bInvalidateTiles);
CPPUNIT_ASSERT_EQUAL(size_t(1), aView1.m_aInvalidations.size());
@@ -1921,7 +1921,7 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testRowColumnHeaders)
SfxLokHelper::setView(nView1);
tools::JsonWriter aJsonWriter1;
pModelObj->getRowColumnHeaders(tools::Rectangle(65,723,10410,4695), aJsonWriter1);
- OString aHeaders1 = aJsonWriter1.extractAsOString();
+ OString aHeaders1 = aJsonWriter1.finishAndGetAsOString();
SfxLokHelper::setView(nView2);
// 50% zoom
@@ -1929,20 +1929,20 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testRowColumnHeaders)
pModelObj->setClientZoom(256, 256, 6636, 6636);
tools::JsonWriter aJsonWriter2;
pModelObj->getRowColumnHeaders(tools::Rectangle(65,723,10410,4695), aJsonWriter2);
- OString aHeaders2 = aJsonWriter2.extractAsOString();
+ OString aHeaders2 = aJsonWriter2.finishAndGetAsOString();
// Check vs. view #1
SfxLokHelper::setView(nView1);
tools::JsonWriter aJsonWriter3;
pModelObj->getRowColumnHeaders(tools::Rectangle(65,723,10410,4695), aJsonWriter3);
- OString aHeaders1_2 = aJsonWriter3.extractAsOString();
+ OString aHeaders1_2 = aJsonWriter3.finishAndGetAsOString();
CPPUNIT_ASSERT_EQUAL(aHeaders1, aHeaders1_2);
// Check vs. view #2
SfxLokHelper::setView(nView2);
tools::JsonWriter aJsonWriter4;
pModelObj->getRowColumnHeaders(tools::Rectangle(65,723,10410,4695), aJsonWriter4);
- OString aHeaders2_2 = aJsonWriter4.extractAsOString();
+ OString aHeaders2_2 = aJsonWriter4.finishAndGetAsOString();
CPPUNIT_ASSERT_EQUAL(aHeaders2, aHeaders2_2);
SfxLokHelper::setView(nView1);