From 57f5f399c6047fa6c484a3b969c84aca3a723fab Mon Sep 17 00:00:00 2001 From: Noel Date: Wed, 3 Feb 2021 08:59:13 +0200 Subject: use more unique_ptr in EnhancedCustomShape2d and fix some leaks in the unit tests Change-Id: I8d324a24de11b14b4820e3cdd7f078d5877489e3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110288 Tested-by: Jenkins Reviewed-by: Noel Grandin --- svx/qa/unit/customshapes.cxx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'svx/qa') diff --git a/svx/qa/unit/customshapes.cxx b/svx/qa/unit/customshapes.cxx index d0d4ac3d3e6d..271a7aad6f19 100644 --- a/svx/qa/unit/customshapes.cxx +++ b/svx/qa/unit/customshapes.cxx @@ -349,7 +349,8 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf121845_two_commands_U) SdrObjCustomShape& rSdrObjCustomShape( static_cast(*GetSdrObjectFromXShape(xShape))); EnhancedCustomShape2d aCustomShape2d(rSdrObjCustomShape); - SdrPathObj* pPathObj = static_cast(aCustomShape2d.CreateLineGeometry()); + SdrPathObjUniquePtr pPathObj( + static_cast(aCustomShape2d.CreateLineGeometry().release())); CPPUNIT_ASSERT_MESSAGE("Could not convert to SdrPathObj", pPathObj); const basegfx::B2DPolyPolygon aPolyPolygon(pPathObj->GetPathPoly()); CPPUNIT_ASSERT_EQUAL_MESSAGE("count polygons", static_cast(2), @@ -777,7 +778,8 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf103474_commandT_CaseZeroHeight) SdrObjCustomShape& rSdrObjCustomShape( static_cast(*GetSdrObjectFromXShape(xShape))); EnhancedCustomShape2d aCustomShape2d(rSdrObjCustomShape); - SdrPathObj* pPathObj = static_cast(aCustomShape2d.CreateLineGeometry()); + SdrPathObjUniquePtr pPathObj( + static_cast(aCustomShape2d.CreateLineGeometry().release())); CPPUNIT_ASSERT_MESSAGE("Could not convert to SdrPathObj", pPathObj); const basegfx::B2DPolyPolygon aPolyPolygon(pPathObj->GetPathPoly()); CPPUNIT_ASSERT_EQUAL_MESSAGE("count polygons", static_cast(1), @@ -807,7 +809,8 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf103474_commandG_CaseZeroHeight) SdrObjCustomShape& rSdrObjCustomShape( static_cast(*GetSdrObjectFromXShape(xShape))); EnhancedCustomShape2d aCustomShape2d(rSdrObjCustomShape); - SdrPathObj* pPathObj = static_cast(aCustomShape2d.CreateLineGeometry()); + SdrPathObjUniquePtr pPathObj( + static_cast(aCustomShape2d.CreateLineGeometry().release())); CPPUNIT_ASSERT_MESSAGE("Could not convert to SdrPathObj", pPathObj); const basegfx::B2DPolyPolygon aPolyPolygon(pPathObj->GetPathPoly()); CPPUNIT_ASSERT_EQUAL_MESSAGE("count polygons", static_cast(1), @@ -837,7 +840,8 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf122323_largeSwingAngle) SdrObjCustomShape& rSdrObjCustomShape( static_cast(*GetSdrObjectFromXShape(xShape))); EnhancedCustomShape2d aCustomShape2d(rSdrObjCustomShape); - SdrPathObj* pPathObj = static_cast(aCustomShape2d.CreateLineGeometry()); + SdrPathObjUniquePtr pPathObj( + static_cast(aCustomShape2d.CreateLineGeometry().release())); CPPUNIT_ASSERT_MESSAGE("Could not convert to SdrPathObj", pPathObj); const basegfx::B2DPolyPolygon aPolyPolygon(pPathObj->GetPathPoly()); const basegfx::B2DPolygon aPolygon(aPolyPolygon.getB2DPolygon(0)); -- cgit