cui/source/customize/CustomNotebookbarGenerator.cxx |   13 ++++++++-----
 desktop/source/lib/init.cxx                         |   12 ++++++++----
 2 files changed, 16 insertions(+), 9 deletions(-)

New commits:
commit c53083fed88e979a55f1cf3cdc9de2628738c073
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Thu Dec 15 20:15:45 2022 +0000
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Fri Dec 16 07:50:17 2022 +0000

    misc: check SfxViewFrame::Current()
    
    these ones look potentially worth backporting
    
    Change-Id: Ie01c0b598c3408f4766318267de8438e997dd1a2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144260
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/cui/source/customize/CustomNotebookbarGenerator.cxx 
b/cui/source/customize/CustomNotebookbarGenerator.cxx
index 9fb71562160a..bae85525ebd6 100644
--- a/cui/source/customize/CustomNotebookbarGenerator.cxx
+++ b/cui/source/customize/CustomNotebookbarGenerator.cxx
@@ -74,11 +74,14 @@ static OUString 
lcl_getAppName(vcl::EnumContext::Application eApp)
 static OUString getAppNameRegistryPath()
 {
     vcl::EnumContext::Application eApp = vcl::EnumContext::Application::Any;
-    const Reference<frame::XFrame>& xFrame
-        = SfxViewFrame::Current()->GetFrame().GetFrameInterface();
-    const Reference<frame::XModuleManager> xModuleManager
-        = 
frame::ModuleManager::create(::comphelper::getProcessComponentContext());
-    eApp = 
vcl::EnumContext::GetApplicationEnum(xModuleManager->identify(xFrame));
+
+    if (SfxViewFrame* pViewFrame = SfxViewFrame::Current())
+    {
+        const Reference<frame::XFrame>& xFrame = 
pViewFrame->GetFrame().GetFrameInterface();
+        const Reference<frame::XModuleManager> xModuleManager
+            = 
frame::ModuleManager::create(::comphelper::getProcessComponentContext());
+        eApp = 
vcl::EnumContext::GetApplicationEnum(xModuleManager->identify(xFrame));
+    }
 
     OUString sAppName(lcl_getAppName(eApp));
     return "org.openoffice.Office.UI.ToolbarMode/Applications/" + sAppName;
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index c777bc7bb731..fd99214e6daa 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -792,6 +792,10 @@ void ExecuteMarginULChange(
 // Main function which toggles page orientation of the Writer doc. Needed by 
ToggleOrientation
 void ExecuteOrientationChange()
 {
+    SfxViewFrame* pViewFrm = SfxViewFrame::Current();
+    if (!pViewFrm)
+        return;
+
     std::unique_ptr<SvxPageItem> pPageItem(new SvxPageItem(SID_ATTR_PAGE));
 
     // 1mm in twips rounded
@@ -799,22 +803,22 @@ void ExecuteOrientationChange()
     constexpr tools::Long MINBODY = o3tl::toTwips(1, o3tl::Length::mm);
 
     css::uno::Reference< css::document::XUndoManager > mxUndoManager(
-                getUndoManager( 
SfxViewFrame::Current()->GetFrame().GetFrameInterface() ) );
+                getUndoManager( pViewFrm->GetFrame().GetFrameInterface() ) );
 
     if ( mxUndoManager.is() )
         mxUndoManager->enterUndoContext( "" );
 
 
     const SvxSizeItem* pSizeItem;
-    
SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_SIZE,
 pSizeItem);
+    pViewFrm->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_SIZE, 
pSizeItem);
     std::unique_ptr<SvxSizeItem> pPageSizeItem(pSizeItem->Clone());
 
     const SvxLongLRSpaceItem* pLRSpaceItem;
-    
SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_LRSPACE,
 pLRSpaceItem);
+    pViewFrm->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_LRSPACE, 
pLRSpaceItem);
     std::unique_ptr<SvxLongLRSpaceItem> 
pPageLRMarginItem(pLRSpaceItem->Clone());
 
     const SvxLongULSpaceItem* pULSpaceItem;
-    
SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_ULSPACE,
 pULSpaceItem);
+    pViewFrm->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_ULSPACE, 
pULSpaceItem);
     std::unique_ptr<SvxLongULSpaceItem> 
pPageULMarginItem(pULSpaceItem->Clone());
 
     {

Reply via email to