chart2/source/controller/main/ChartTransferable.cxx | 7 +++---- chart2/source/controller/main/ChartTransferable.hxx | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-)
New commits: commit d2ecb536394f52f1fd7bce53d8feb202a3facfdd Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Mon Sep 12 12:40:21 2022 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Tue Sep 13 17:50:28 2022 +0200 cid#1500679 Resource leak in object to reproduce this in reality, insert a chart, activate it, select and copy and paste something like a bar of a bar chart. Select that copy and copy to clipboard again. reactivate chart, paste that element into the surrounding spreadsheet, select and copy something else to clear the chart transferrable and the model created by the chart transferrable leaks. there are an unrelated blizzard of a11y mutex deadlocks here btw :-( Change-Id: I650885d8c784cc1b2b023af8f5e23b3dceb2d9f3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139794 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/chart2/source/controller/main/ChartTransferable.cxx b/chart2/source/controller/main/ChartTransferable.cxx index 322e73be3aa8..2f27902ba1e3 100644 --- a/chart2/source/controller/main/ChartTransferable.cxx +++ b/chart2/source/controller/main/ChartTransferable.cxx @@ -49,8 +49,7 @@ ChartTransferable::ChartTransferable( SdrModel& rSdrModel, SdrObject* pSelectedObj, bool bDrawing) -: m_pMarkedObjModel( nullptr ) - ,m_bDrawing( bDrawing ) + : m_bDrawing(bDrawing) { std::unique_ptr<SdrExchangeView> pExchgView(std::make_unique<SdrView>( rSdrModel )); SdrPageView* pPv = pExchgView->ShowSdrPage( rSdrModel.GetPage( 0 )); @@ -62,7 +61,7 @@ ChartTransferable::ChartTransferable( m_xMetaFileGraphic.set( aGraphic.GetXGraphic()); if ( m_bDrawing ) { - m_pMarkedObjModel = pExchgView->CreateMarkedObjModel().release(); + m_xMarkedObjModel = pExchgView->CreateMarkedObjModel(); } } @@ -89,7 +88,7 @@ bool ChartTransferable::GetData( const css::datatransfer::DataFlavor& rFlavor, c { if ( nFormat == SotClipboardFormatId::DRAWING ) { - bResult = SetObject( m_pMarkedObjModel, CHARTTRANSFER_OBJECTTYPE_DRAWMODEL, rFlavor ); + bResult = SetObject(m_xMarkedObjModel.get(), CHARTTRANSFER_OBJECTTYPE_DRAWMODEL, rFlavor); } else if ( nFormat == SotClipboardFormatId::GDIMETAFILE ) { diff --git a/chart2/source/controller/main/ChartTransferable.hxx b/chart2/source/controller/main/ChartTransferable.hxx index 34567dceb6a9..fd782864bfc6 100644 --- a/chart2/source/controller/main/ChartTransferable.hxx +++ b/chart2/source/controller/main/ChartTransferable.hxx @@ -51,7 +51,7 @@ protected: private: css::uno::Reference< css::graphic::XGraphic > m_xMetaFileGraphic; - SdrModel* m_pMarkedObjModel; + std::unique_ptr<SdrModel> m_xMarkedObjModel; bool m_bDrawing; };