From 4a9c9488ee918879e89751a15f3ef0fcbbcd2070 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 15 Dec 2022 20:25:27 +0000 Subject: sd: check SfxViewFrame::Current() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SfxViewFrame::Current() is a festering wound, these ones look like they were safe anyway, so no need to backport. But with enough checked static analysis will kick in to flag new unchecked ones. Change-Id: Ife81c0e5fc508d8eb30808884c61b8e8c6723890 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144279 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- sd/source/ui/docshell/docshel4.cxx | 15 +++++++++------ sd/source/ui/docshell/docshell.cxx | 4 +--- 2 files changed, 10 insertions(+), 9 deletions(-) (limited to 'sd/source/ui/docshell') diff --git a/sd/source/ui/docshell/docshel4.cxx b/sd/source/ui/docshell/docshel4.cxx index 13b08deafa1a..99d6890fe1f0 100644 --- a/sd/source/ui/docshell/docshel4.cxx +++ b/sd/source/ui/docshell/docshel4.cxx @@ -851,12 +851,14 @@ void DrawDocShell::GotoBookmark(std::u16string_view rBookmark) } } - SfxBindings& rBindings = ((pDrawViewShell && pDrawViewShell->GetViewFrame()!=nullptr) + if (SfxViewFrame* pViewFrame = (pDrawViewShell && pDrawViewShell->GetViewFrame()) ? pDrawViewShell->GetViewFrame() - : SfxViewFrame::Current() )->GetBindings(); - - rBindings.Invalidate(SID_NAVIGATOR_STATE, true); - rBindings.Invalidate(SID_NAVIGATOR_PAGENAME); + : SfxViewFrame::Current()) + { + SfxBindings& rBindings = pViewFrame->GetBindings(); + rBindings.Invalidate(SID_NAVIGATOR_STATE, true); + rBindings.Invalidate(SID_NAVIGATOR_PAGENAME); + } } /** @@ -964,7 +966,8 @@ void DrawDocShell::OpenBookmark( const OUString& rBookmarkURL ) SfxStringItem aStrItem( SID_FILE_NAME, rBookmarkURL ); SfxStringItem aReferer( SID_REFERER, GetMedium()->GetName() ); const SfxPoolItem* ppArgs[] = { &aStrItem, &aReferer, nullptr }; - ( mpViewShell ? mpViewShell->GetViewFrame() : SfxViewFrame::Current() )->GetBindings().Execute( SID_OPENHYPERLINK, ppArgs ); + if (SfxViewFrame* pFrame = mpViewShell ? mpViewShell->GetViewFrame() : SfxViewFrame::Current()) + pFrame->GetBindings().Execute( SID_OPENHYPERLINK, ppArgs ); } std::shared_ptr DrawDocShell::CreateDocumentInfoDialog(weld::Window* pParent, const SfxItemSet &rSet) diff --git a/sd/source/ui/docshell/docshell.cxx b/sd/source/ui/docshell/docshell.cxx index 78279687a039..d837092eba68 100644 --- a/sd/source/ui/docshell/docshell.cxx +++ b/sd/source/ui/docshell/docshell.cxx @@ -336,9 +336,7 @@ void DrawDocShell::GetState(SfxItemSet &rSet) nWhich = aIter.NextWhich(); } - SfxViewFrame* pFrame = SfxViewFrame::Current(); - - if (pFrame) + if (SfxViewFrame* pFrame = SfxViewFrame::Current()) { if (rSet.GetItemState(SID_RELOAD) != SfxItemState::UNKNOWN) { -- cgit