chart2/source/controller/main/ChartController_Tools.cxx |   18 +++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

New commits:
commit 11a3e5707d6b524728b24e170eb542bba273d811
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Sun Feb 13 16:57:47 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sun Feb 13 19:48:14 2022 +0100

    tdf#147394 delete crash legend
    
    regression from
        commit 63e8c2ccd39263b24f644c3d0394044a2613eb88
        Author: Noel Grandin <noelgran...@gmail.com>
        Date:   Sat Jan 29 21:21:27 2022 +0200
        use more concrete types in chart2, Diagram
    
    Change-Id: I6598bb7c116bd94272a805e77751aa8cf5dc174a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129882
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/chart2/source/controller/main/ChartController_Tools.cxx 
b/chart2/source/controller/main/ChartController_Tools.cxx
index ccf18ae37d15..92035d9d1bbd 100644
--- a/chart2/source/controller/main/ChartController_Tools.cxx
+++ b/chart2/source/controller/main/ChartController_Tools.cxx
@@ -616,13 +616,17 @@ bool ChartController::executeDispatch_Delete()
                 rtl::Reference< Diagram > xDiagram( 
xChartDoc->getFirstChartDiagram());
                 if( xDiagram.is())
                 {
-                    UndoGuard aUndoGuard(
-                        ActionDescriptionProvider::createDescription(
-                            ActionDescriptionProvider::ActionType::Delete, 
SchResId( STR_OBJECT_LEGEND )),
-                        m_xUndoManager );
-                    xDiagram->setPropertyValue( "Show", uno::Any( false ));
-                    bReturn = true;
-                    aUndoGuard.commit();
+                    uno::Reference< beans::XPropertySet > xLegendProp( 
xDiagram->getLegend(), uno::UNO_QUERY );
+                    if( xLegendProp.is())
+                    {
+                        UndoGuard aUndoGuard(
+                            ActionDescriptionProvider::createDescription(
+                                ActionDescriptionProvider::ActionType::Delete, 
SchResId( STR_OBJECT_LEGEND )),
+                            m_xUndoManager );
+                        xLegendProp->setPropertyValue( "Show", uno::Any( false 
));
+                        bReturn = true;
+                        aUndoGuard.commit();
+                    }
                 }
                 break;
             }

Reply via email to