svx/source/dialog/srchdlg.cxx | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-)
New commits: commit 257d80b4ab086aae504694d37e43c5b1a7d9a386 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Wed Jun 22 11:02:43 2022 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Wed Jun 22 13:38:49 2022 +0200 crashreporting: apparent null derefs of SfxViewFrame::Current() Change-Id: I0e2c07a7eaa0a13be0a44c7cd187feec8ed4c2c7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136277 Tested-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/svx/source/dialog/srchdlg.cxx b/svx/source/dialog/srchdlg.cxx index 1efaa5d8f1ae..b047ef27d1e7 100644 --- a/svx/source/dialog/srchdlg.cxx +++ b/svx/source/dialog/srchdlg.cxx @@ -2344,16 +2344,12 @@ SfxChildWinInfo SvxSearchDialogWrapper::GetInfo() const return aInfo; } -static void lcl_SetSearchLabelWindow(const OUString& rStr) +static void lcl_SetSearchLabelWindow(const OUString& rStr, SfxViewFrame& rViewFrame) { - SfxViewFrame* pViewFrame = SfxViewFrame::Current(); - if (!pViewFrame) - return; - bool bNotFound = rStr == SvxResId(RID_SVXSTR_SEARCH_NOT_FOUND); css::uno::Reference< css::beans::XPropertySet > xPropSet( - pViewFrame->GetFrame().GetFrameInterface(), css::uno::UNO_QUERY_THROW); + rViewFrame.GetFrame().GetFrameInterface(), css::uno::UNO_QUERY_THROW); css::uno::Reference< css::frame::XLayoutManager > xLayoutManager; xPropSet->getPropertyValue("LayoutManager") >>= xLayoutManager; css::uno::Reference< css::ui::XUIElement > xUIElement = @@ -2424,6 +2420,10 @@ OUString SvxSearchDialogWrapper::GetSearchLabel() void SvxSearchDialogWrapper::SetSearchLabel(const SearchLabel& rSL) { + SfxViewFrame* pViewFrame = SfxViewFrame::Current(); + if (!pViewFrame) + return; + OUString sStr; if (rSL == SearchLabel::End) sStr = SvxResId(RID_SVXSTR_SEARCH_END); @@ -2444,17 +2444,21 @@ void SvxSearchDialogWrapper::SetSearchLabel(const SearchLabel& rSL) else if (rSL == SearchLabel::ReminderStartWrapped) sStr = SvxResId(RID_SVXSTR_SEARCH_REMINDER_START_WRAPPED); - lcl_SetSearchLabelWindow(sStr); - if (SvxSearchDialogWrapper *pWrp = static_cast<SvxSearchDialogWrapper*>( SfxViewFrame::Current()-> + lcl_SetSearchLabelWindow(sStr, *pViewFrame); + + if (SvxSearchDialogWrapper *pWrp = static_cast<SvxSearchDialogWrapper*>( pViewFrame-> GetChildWindow( SvxSearchDialogWrapper::GetChildWindowId() ))) pWrp->getDialog()->SetSearchLabel(sStr); } void SvxSearchDialogWrapper::SetSearchLabel(const OUString& sStr) { + SfxViewFrame* pViewFrame = SfxViewFrame::Current(); + if (!pViewFrame) + return; - lcl_SetSearchLabelWindow(sStr); - if (SvxSearchDialogWrapper *pWrp = static_cast<SvxSearchDialogWrapper*>( SfxViewFrame::Current()-> + lcl_SetSearchLabelWindow(sStr, *pViewFrame); + if (SvxSearchDialogWrapper *pWrp = static_cast<SvxSearchDialogWrapper*>( pViewFrame-> GetChildWindow( SvxSearchDialogWrapper::GetChildWindowId() ))) pWrp->getDialog()->SetSearchLabel(sStr); }