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>
diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx
index 5f9e971..bffd841 100644
--- a/chart2/source/controller/main/ChartController.cxx
+++ b/chart2/source/controller/main/ChartController.cxx
@@ -1428,7 +1428,7 @@
        {
            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 29c6d0a..acf8125 100644
--- a/chart2/source/controller/main/UndoActions.cxx
+++ b/chart2/source/controller/main/UndoActions.cxx
@@ -85,10 +85,10 @@

// = 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 @@

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 598bf4f..fb7f5f3 100644
--- a/chart2/source/controller/main/UndoActions.hxx
+++ b/chart2/source/controller/main/UndoActions.hxx
@@ -89,7 +89,7 @@
                        ,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 @@
    virtual ~ShapeUndoElement() override;

private:
    SdrUndoAction*  m_pAction;
    std::unique_ptr<SdrUndoAction> m_xAction;
};

} // namespace impl