svx/source/dialog/srchdlg.cxx | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-)
New commits: commit 13161a02952470d06e86cbed711ce69c93e10bca 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:27:50 2022 +0200 crashreporting: apparent null derefs of SfxViewFrame::Current() Change-Id: I0e2c07a7eaa0a13be0a44c7cd187feec8ed4c2c7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136241 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/svx/source/dialog/srchdlg.cxx b/svx/source/dialog/srchdlg.cxx index ba5def14777e..1f77456477d4 100644 --- a/svx/source/dialog/srchdlg.cxx +++ b/svx/source/dialog/srchdlg.cxx @@ -2342,16 +2342,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 = @@ -2422,6 +2418,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); @@ -2442,17 +2442,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); }