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(-)

New commits:
commit b3a83c1e0b48eeb5b62ec450dff58463bcb12f1e
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Thu Dec 15 20:00:26 2022 +0000
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Fri Dec 16 19:45:43 2022 +0000

    sfx2: check SfxViewFrame::Current()
    
    these ones look potentially worth backporting
    
    Change-Id: I9391f266b08e3842f9686db6113b61fa814f3fbb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144258
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    (cherry picked from commit 59842f25ce457bdddc5cdddbe95dda76d09353cd)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144299
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    Reviewed-by: Caolán McNamara <caol...@redhat.com>
    Tested-by: Caolán McNamara <caol...@redhat.com>

diff --git a/sfx2/source/appl/app.cxx b/sfx2/source/appl/app.cxx
index cd4acc552132..4a85e28f2d16 100644
--- a/sfx2/source/appl/app.cxx
+++ b/sfx2/source/appl/app.cxx
@@ -422,7 +422,7 @@ IMPL_STATIC_LINK( SfxApplication, GlobalBasicErrorHdl_Impl, 
StarBASIC*, pStarBas
             const SfxViewFrame* pViewFrame = SfxViewFrame::Current();
             std::shared_ptr<weld::MessageDialog> 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<frame::XFrame> xFrame = 
SfxViewFrame::Current()->GetFrame().GetFrameInterface();
-    comphelper::dispatchCommand(".uno:InsertSymbol", xFrame, {});
+    if (SfxViewFrame* pViewFrm = SfxViewFrame::Current())
+    {
+        uno::Reference<frame::XFrame> 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())

Reply via email to