diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-03-25 11:34:07 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-03-25 12:59:34 +0100 |
commit | dec5b1191d18a059b63cf2d66b1ce95703804079 (patch) | |
tree | 6216ca62e419884e4ae2c22b21e6ee0df2c1796e | |
parent | 756252ce13f541049af620983f6741223d44573b (diff) |
tdf#124112 Insert drawing object in chart crashes LibreOffice
regression from
commit 6be7e2e9dd8027d284f1b00ef6e3b4654eec7d79
Date: Thu Aug 30 13:54:33 2018 +0200
pass SdrUndoAction around by std::unique_ptr
Looks like previously this memory was just leaked, so fix that and the
crash
Change-Id: I5eb5c104dccd82cef30af533ce1fe8546ced0ea0
Reviewed-on: https://gerrit.libreoffice.org/69648
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | chart2/source/controller/main/ChartController.cxx | 2 | ||||
-rw-r--r-- | chart2/source/controller/main/UndoActions.cxx | 16 | ||||
-rw-r--r-- | chart2/source/controller/main/UndoActions.hxx | 4 |
3 files changed, 11 insertions, 11 deletions
diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx index 5f9e97148a96..bffd841f415d 100644 --- a/chart2/source/controller/main/ChartController.cxx +++ b/chart2/source/controller/main/ChartController.cxx @@ -1428,7 +1428,7 @@ void ChartController::NotifyUndoActionHdl( std::unique_ptr<SdrUndoAction> pUndoA { const Reference< document::XUndoManagerSupplier > xSuppUndo( getModel(), uno::UNO_QUERY_THROW ); const Reference< document::XUndoManager > xUndoManager( xSuppUndo->getUndoManager(), uno::UNO_QUERY_THROW ); - const Reference< document::XUndoAction > xAction( new impl::ShapeUndoElement( *pUndoAction ) ); + const Reference< document::XUndoAction > xAction( new impl::ShapeUndoElement( std::move(pUndoAction) ) ); xUndoManager->addUndoAction( xAction ); } catch( const uno::Exception& ) diff --git a/chart2/source/controller/main/UndoActions.cxx b/chart2/source/controller/main/UndoActions.cxx index 29c6d0ac7b62..acf812554cae 100644 --- a/chart2/source/controller/main/UndoActions.cxx +++ b/chart2/source/controller/main/UndoActions.cxx @@ -85,10 +85,10 @@ void SAL_CALL UndoElement::redo( ) // = ShapeUndoElement -ShapeUndoElement::ShapeUndoElement( SdrUndoAction& i_sdrUndoAction ) +ShapeUndoElement::ShapeUndoElement( std::unique_ptr<SdrUndoAction> xSdrUndoAction ) :ShapeUndoElement_MBase() ,ShapeUndoElement_TBase( m_aMutex ) - ,m_pAction( &i_sdrUndoAction ) + ,m_xAction( std::move(xSdrUndoAction) ) { } @@ -98,23 +98,23 @@ ShapeUndoElement::~ShapeUndoElement() OUString SAL_CALL ShapeUndoElement::getTitle() { - if ( !m_pAction ) + if ( !m_xAction ) throw DisposedException( OUString(), *this ); - return m_pAction->GetComment(); + return m_xAction->GetComment(); } void SAL_CALL ShapeUndoElement::undo( ) { - if ( !m_pAction ) + if ( !m_xAction ) throw DisposedException( OUString(), *this ); - m_pAction->Undo(); + m_xAction->Undo(); } void SAL_CALL ShapeUndoElement::redo( ) { - if ( !m_pAction ) + if ( !m_xAction ) throw DisposedException( OUString(), *this ); - m_pAction->Redo(); + m_xAction->Redo(); } void SAL_CALL ShapeUndoElement::disposing() diff --git a/chart2/source/controller/main/UndoActions.hxx b/chart2/source/controller/main/UndoActions.hxx index 598bf4f25430..fb7f5f3a07ff 100644 --- a/chart2/source/controller/main/UndoActions.hxx +++ b/chart2/source/controller/main/UndoActions.hxx @@ -89,7 +89,7 @@ class ShapeUndoElement :public ShapeUndoElement_MBase ,public ShapeUndoElement_TBase { public: - explicit ShapeUndoElement( SdrUndoAction& i_sdrUndoAction ); + explicit ShapeUndoElement( std::unique_ptr<SdrUndoAction> xSdrUndoAction ); // XUndoAction virtual OUString SAL_CALL getTitle() override; @@ -103,7 +103,7 @@ protected: virtual ~ShapeUndoElement() override; private: - SdrUndoAction* m_pAction; + std::unique_ptr<SdrUndoAction> m_xAction; }; } // namespace impl |