From 06065b600d7ff84baf83f2485455be816d0cd9b8 Mon Sep 17 00:00:00 2001 From: László Németh Date: Mon, 27 Feb 2023 11:20:09 +0100 Subject: tdf#153858 sw: crash fix for chart with deleted data table MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using mouse, e.g. simply moving the mouse pointer during editing a chart with a deleted data table crashed Writer immediately. Follow-up to commit 5b9855acc7fa6d1e4a5f53ff0bc47e1dd4729827 "tdf#132714 sw: fix crash at table row deletion associated to a chart". Change-Id: I6d89eabc84565c548e2d9ded922789d623367ce4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147882 Tested-by: László Németh Reviewed-by: László Németh (cherry picked from commit 4f2dcc4bc70c3602e2612dab611b610410637920) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147898 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- .../controller/dialogs/ObjectNameProvider.cxx | 26 +++++++++++++--------- chart2/source/tools/DataSeriesHelper.cxx | 13 ++++++++--- 2 files changed, 26 insertions(+), 13 deletions(-) (limited to 'chart2') diff --git a/chart2/source/controller/dialogs/ObjectNameProvider.cxx b/chart2/source/controller/dialogs/ObjectNameProvider.cxx index 2bf6af625555..c60ff1ca364a 100644 --- a/chart2/source/controller/dialogs/ObjectNameProvider.cxx +++ b/chart2/source/controller/dialogs/ObjectNameProvider.cxx @@ -124,13 +124,15 @@ OUString lcl_getDataPointValueText( const rtl::Reference< DataSeries >& xSeries, uno::Reference xDataSequence( aDataSequences[nN]->getValues()); if( !xDataSequence.is() ) continue; - Sequence< Any > aData( xDataSequence->getData() ); - if( nPointIndex >= aData.getLength() ) - continue; - uno::Reference xProp(xDataSequence, uno::UNO_QUERY ); - if( xProp.is()) + + try { - try + Sequence< Any > aData( xDataSequence->getData() ); + + if( nPointIndex >= aData.getLength() ) + continue; + uno::Reference xProp(xDataSequence, uno::UNO_QUERY ); + if( xProp.is()) { uno::Any aARole = xProp->getPropertyValue( "Role" ); OUString aRole; @@ -179,10 +181,14 @@ OUString lcl_getDataPointValueText( const rtl::Reference< DataSeries >& xSeries, a_Size = aNumberFormatterWrapper.getFormattedString( nNumberFormatKey, fValue, nLabelColor, bColorChanged ); } } - catch( const uno::Exception& ) - { - TOOLS_WARN_EXCEPTION("chart2", "" ); - } + } + catch (const lang::DisposedException&) + { + TOOLS_WARN_EXCEPTION( "chart2", "unexpected exception caught" ); + } + catch( const uno::Exception& ) + { + TOOLS_WARN_EXCEPTION("chart2", "" ); } } diff --git a/chart2/source/tools/DataSeriesHelper.cxx b/chart2/source/tools/DataSeriesHelper.cxx index e2bc3cfbe7d0..47b3ad979b05 100644 --- a/chart2/source/tools/DataSeriesHelper.cxx +++ b/chart2/source/tools/DataSeriesHelper.cxx @@ -208,10 +208,17 @@ uno::Reference< chart2::data::XLabeledDataSequence > if( ! xSource.is()) return aNoResult; const Sequence< Reference< chart2::data::XLabeledDataSequence > > aLabeledSeq( xSource->getDataSequences()); - for (auto const & i : aLabeledSeq) + try + { + for (auto const & i : aLabeledSeq) + { + if (lcl_MatchesRole(aRole, bMatchPrefix)(i)) + return i; + } + } + catch (const lang::DisposedException&) { - if (lcl_MatchesRole(aRole, bMatchPrefix)(i)) - return i; + TOOLS_WARN_EXCEPTION( "chart2", "unexpected exception caught" ); } return aNoResult; -- cgit v1.2.3