From c70c85b67c5f5e046eacfcabcde37edc58653f35 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 15 Dec 2022 20:00:26 +0000 Subject: sfx2: check SfxViewFrame::Current() these ones look potentially worth backporting Change-Id: I9391f266b08e3842f9686db6113b61fa814f3fbb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144257 Tested-by: Jenkins Reviewed-by: Xisco Fauli --- sfx2/source/appl/app.cxx | 2 +- sfx2/source/commandpopup/CommandPopup.cxx | 2 ++ sfx2/source/control/charmapcontrol.cxx | 7 +++++-- sfx2/source/control/request.cxx | 8 +++++++- 4 files changed, 15 insertions(+), 4 deletions(-) (limited to 'sfx2') diff --git a/sfx2/source/appl/app.cxx b/sfx2/source/appl/app.cxx index 4b5adbdf8a2b..3d3adb84bfe4 100644 --- a/sfx2/source/appl/app.cxx +++ b/sfx2/source/appl/app.cxx @@ -410,7 +410,7 @@ IMPL_STATIC_LINK( SfxApplication, GlobalBasicErrorHdl_Impl, StarBASIC*, pStarBas const SfxViewFrame* pViewFrame = SfxViewFrame::Current(); std::shared_ptr xBox; xBox.reset(Application::CreateMessageDialog( - pViewFrame->GetFrameWeld(), + pViewFrame ? pViewFrame->GetFrameWeld() : nullptr, VclMessageType::Error, VclButtonsType::Ok, aError, diff --git a/sfx2/source/commandpopup/CommandPopup.cxx b/sfx2/source/commandpopup/CommandPopup.cxx index 47df143a889b..f4cdf92436c7 100644 --- a/sfx2/source/commandpopup/CommandPopup.cxx +++ b/sfx2/source/commandpopup/CommandPopup.cxx @@ -152,6 +152,8 @@ void MenuContentHandler::addCommandIfPossible( return; auto* pViewFrame = SfxViewFrame::Current(); + if (!pViewFrame) + return; SfxSlotPool& rSlotPool = SfxSlotPool::GetSlotPool(pViewFrame); const SfxSlot* pSlot = rSlotPool.GetUnoSlot(aCommandURL.Path); diff --git a/sfx2/source/control/charmapcontrol.cxx b/sfx2/source/control/charmapcontrol.cxx index 032306b8a85f..a79da745be26 100644 --- a/sfx2/source/control/charmapcontrol.cxx +++ b/sfx2/source/control/charmapcontrol.cxx @@ -207,8 +207,11 @@ IMPL_LINK_NOARG(SfxCharmapCtrl, OpenDlgHdl, weld::Button&, void) { m_xControl->EndPopupMode(); - uno::Reference xFrame = SfxViewFrame::Current()->GetFrame().GetFrameInterface(); - comphelper::dispatchCommand(".uno:InsertSymbol", xFrame, {}); + if (SfxViewFrame* pViewFrm = SfxViewFrame::Current()) + { + uno::Reference xFrame = pViewFrm->GetFrame().GetFrameInterface(); + comphelper::dispatchCommand(".uno:InsertSymbol", xFrame, {}); + } } void SfxCharmapCtrl::GrabFocus() diff --git a/sfx2/source/control/request.cxx b/sfx2/source/control/request.cxx index 964a256b19a7..b43d1dd991bc 100644 --- a/sfx2/source/control/request.cxx +++ b/sfx2/source/control/request.cxx @@ -687,8 +687,14 @@ css::uno::Reference< css::frame::XDispatchRecorder > SfxRequest::GetMacroRecorde { css::uno::Reference< css::frame::XDispatchRecorder > xRecorder; + if (!pView) + pView = SfxViewFrame::Current(); + + if (!pView) + return xRecorder; + css::uno::Reference< css::beans::XPropertySet > xSet( - (pView ? pView : SfxViewFrame::Current())->GetFrame().GetFrameInterface(), + pView->GetFrame().GetFrameInterface(), css::uno::UNO_QUERY); if(xSet.is()) -- cgit