sw/source/core/access/accselectionhelper.cxx |   13 +++++--------
 sw/source/core/doc/tblrwcl.cxx               |    6 ++++--
 sw/source/core/docnode/ndtbl.cxx             |   22 +++++++++++++++-------
 sw/source/core/undo/untbl.cxx                |    3 ++-
 sw/source/core/unocore/unotbl.cxx            |    3 ++-
 sw/source/ui/vba/vbadocumentproperties.cxx   |    5 +----
 sw/source/ui/vba/vbaselection.cxx            |    5 +----
 sw/source/uibase/app/docst.cxx               |    7 +++++--
 sw/source/uibase/shells/textsh1.cxx          |    3 ++-
 9 files changed, 37 insertions(+), 30 deletions(-)

New commits:
commit 8a0be96c7ccbd433b5cba5d9d814178cf8a5d026
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Wed Feb 15 17:06:33 2023 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Thu Feb 16 10:11:52 2023 +0000

    check GetFEShell()
    
    Similar to 24889135773204c6e3002dcb417c75ff1a99ccd0
    "check GetEditShell()"
    
    These two crash reports might be related:
    - https://crashreport.libreoffice.org/stats/signature/SwView::GetDocShell()
    - 
https://crashreport.libreoffice.org/stats/signature/SwFEShell::UpdateTableStyleFormatting(SwTableNode%20*,bool,rtl::OUString%20const%20*)
    
    Change-Id: I7ce286f7be933b34af270abd11a4c9c4c58fe4a8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147117
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/sw/source/core/access/accselectionhelper.cxx 
b/sw/source/core/access/accselectionhelper.cxx
index 3372f434c5a1..96a622ece9f7 100644
--- a/sw/source/core/access/accselectionhelper.cxx
+++ b/sw/source/core/access/accselectionhelper.cxx
@@ -87,8 +87,7 @@ void SwAccessibleSelectionHelper::selectAccessibleChild(
 
     // we can only select fly frames, so we ignore (should: return
     // false) all other attempts at child selection
-    SwFEShell* pFEShell = GetFEShell();
-    if( pFEShell != nullptr )
+    if (GetFEShell())
     {
         const SdrObject *pObj = aChild.GetDrawObject();
         if( pObj )
@@ -141,8 +140,7 @@ bool SwAccessibleSelectionHelper::isAccessibleChildSelected(
 
     // ... and compare to the currently selected frame
     bool bRet = false;
-    const SwFEShell* pFEShell = GetFEShell();
-    if( pFEShell )
+    if (const SwFEShell* pFEShell = GetFEShell())
     {
         if ( aChild.GetSwFrame() != nullptr )
         {
@@ -171,7 +169,7 @@ void 
SwAccessibleSelectionHelper::selectAllAccessibleChildren(  )
     // the first we can select, and select it.
 
     SwFEShell* pFEShell = GetFEShell();
-    if( !pFEShell )
+    if (!pFEShell)
         return;
 
     std::list< SwAccessibleChild > aChildren;
@@ -197,8 +195,7 @@ sal_Int32 
SwAccessibleSelectionHelper::getSelectedAccessibleChildCount(  )
     sal_Int32 nCount = 0;
     // Only one frame can be selected at a time, and we only frames
     // for selectable children.
-    const SwFEShell* pFEShell = GetFEShell();
-    if( pFEShell != nullptr )
+    if (const SwFEShell* pFEShell = GetFEShell())
     {
         const SwFlyFrame* pFlyFrame = pFEShell->GetSelectedFlyFrame();
         if( pFlyFrame )
@@ -250,7 +247,7 @@ Reference<XAccessible> 
SwAccessibleSelectionHelper::getSelectedAccessibleChild(
     // be 0, and a selection must exist, otherwise we have to throw an
     // lang::IndexOutOfBoundsException
     SwFEShell* pFEShell = GetFEShell();
-    if( nullptr == pFEShell )
+    if (!pFEShell)
         throwIndexOutOfBoundsException();
 
     SwAccessibleChild aChild;
diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx
index 4dde7b3e6192..b169b9d8391b 100644
--- a/sw/source/core/doc/tblrwcl.cxx
+++ b/sw/source/core/doc/tblrwcl.cxx
@@ -506,7 +506,8 @@ bool SwTable::InsertCol( SwDoc& rDoc, const SwSelBoxes& 
rBoxes, sal_uInt16 nCnt,
         pPCD->AddRowCols( *this, rBoxes, nCnt, bBehind );
     rDoc.UpdateCharts( GetFrameFormat()->GetName() );
 
-    rDoc.GetDocShell()->GetFEShell()->UpdateTableStyleFormatting();
+    if (SwFEShell* pFEShell = rDoc.GetDocShell()->GetFEShell())
+        pFEShell->UpdateTableStyleFormatting();
 
     return bRes;
 }
@@ -625,7 +626,8 @@ bool SwTable::InsertRow_( SwDoc* pDoc, const SwSelBoxes& 
rBoxes,
         pPCD->AddRowCols( *this, rBoxes, nCnt, bBehind );
     pDoc->UpdateCharts( GetFrameFormat()->GetName() );
 
-    pDoc->GetDocShell()->GetFEShell()->UpdateTableStyleFormatting(pTableNd);
+    if (SwFEShell* pFEShell = pDoc->GetDocShell()->GetFEShell())
+        pFEShell->UpdateTableStyleFormatting(pTableNd);
 
     return true;
 }
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index 4a6ee962f65a..edeb5b7cb2ba 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -2101,7 +2101,8 @@ bool SwDoc::DeleteRowCol(const SwSelBoxes& rBoxes, 
RowColMode const eMode)
             getIDocumentContentOperations().DeleteSection( pTableNd );
         }
 
-        GetDocShell()->GetFEShell()->UpdateTableStyleFormatting();
+        if (SwFEShell* pFEShell = GetDocShell()->GetFEShell())
+            pFEShell->UpdateTableStyleFormatting();
 
         getIDocumentState().SetModified();
         getIDocumentFieldsAccess().SetFieldsDirty( true, nullptr, 
SwNodeOffset(0) );
@@ -2135,7 +2136,8 @@ bool SwDoc::DeleteRowCol(const SwSelBoxes& rBoxes, 
RowColMode const eMode)
         bRet = rTable.DeleteSel( this, aSelBoxes, nullptr, pUndo.get(), true, 
true );
         if (bRet)
         {
-            GetDocShell()->GetFEShell()->UpdateTableStyleFormatting();
+            if (SwFEShell* pFEShell = GetDocShell()->GetFEShell())
+                pFEShell->UpdateTableStyleFormatting();
 
             getIDocumentState().SetModified();
             getIDocumentFieldsAccess().SetFieldsDirty( true, nullptr, 
SwNodeOffset(0) );
@@ -2200,7 +2202,8 @@ bool SwDoc::SplitTable( const SwSelBoxes& rBoxes, bool 
bVert, sal_uInt16 nCnt,
 
         if (bRet)
         {
-            GetDocShell()->GetFEShell()->UpdateTableStyleFormatting();
+            if (SwFEShell* pFEShell = GetDocShell()->GetFEShell())
+                pFEShell->UpdateTableStyleFormatting();
 
             getIDocumentState().SetModified();
             getIDocumentFieldsAccess().SetFieldsDirty( true, nullptr, 
SwNodeOffset(0) );
@@ -3248,8 +3251,11 @@ void SwDoc::SplitTable( const SwPosition& rPos, 
SplitTable_HeadlineOption eHdlnM
     UpdateCharts( rTable.GetFrameFormat()->GetName() );
 
     // update table style formatting of both the tables
-    GetDocShell()->GetFEShell()->UpdateTableStyleFormatting(pTNd);
-    GetDocShell()->GetFEShell()->UpdateTableStyleFormatting(pNew);
+    if (SwFEShell* pFEShell = GetDocShell()->GetFEShell())
+    {
+        pFEShell->UpdateTableStyleFormatting(pTNd);
+        pFEShell->UpdateTableStyleFormatting(pNew);
+    }
 
     getIDocumentFieldsAccess().SetFieldsDirty( true, nullptr, SwNodeOffset(0) 
);
 }
@@ -3527,7 +3533,8 @@ bool SwDoc::MergeTable( const SwPosition& rPos, bool 
bWithPrev, sal_uInt16 nMode
     }
     if( bRet )
     {
-        GetDocShell()->GetFEShell()->UpdateTableStyleFormatting();
+        if (SwFEShell* pFEShell = GetDocShell()->GetFEShell())
+            pFEShell->UpdateTableStyleFormatting();
 
         getIDocumentState().SetModified();
         getIDocumentFieldsAccess().SetFieldsDirty( true, nullptr, 
SwNodeOffset(0) );
@@ -4658,7 +4665,8 @@ void SwDoc::ChgTableStyle(const OUString& rName, const 
SwTableAutoFormat& rNewFo
         SwFrameFormat* pFrameFormat = &GetTableFrameFormat(i, true);
         SwTable* pTable = SwTable::FindTable(pFrameFormat);
         if (pTable->GetTableStyleName() == rName)
-            
GetDocShell()->GetFEShell()->UpdateTableStyleFormatting(pTable->GetTableNode());
+            if (SwFEShell* pFEShell = GetDocShell()->GetFEShell())
+                pFEShell->UpdateTableStyleFormatting(pTable->GetTableNode());
     }
 
     getIDocumentState().SetModified();
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index 2b97f8dbfbdb..49453108b2be 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -1793,7 +1793,8 @@ void SwUndoTableNdsChg::UndoImpl(::sw::UndoRedoContext & 
rContext)
 
     // TL_CHART2: need to inform chart of probably changed cell names
     rDoc.UpdateCharts( pTableNd->GetTable().GetFrameFormat()->GetName() );
-    rDoc.GetDocShell()->GetFEShell()->UpdateTableStyleFormatting(pTableNd);
+    if (SwFEShell* pFEShell = rDoc.GetDocShell()->GetFEShell())
+        pFEShell->UpdateTableStyleFormatting(pTableNd);
     if( IsDelBox() )
         m_nSttNode = pTableNd->GetIndex();
     ClearFEShellTabCols(rDoc, nullptr);
diff --git a/sw/source/core/unocore/unotbl.cxx 
b/sw/source/core/unocore/unotbl.cxx
index 90df0f543428..801f6cc954c6 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -2690,7 +2690,8 @@ void SwXTextTable::setPropertyValue(const OUString& 
rPropertyName, const uno::An
                     SwStyleNameMapper::FillUIName(sName, sName, 
SwGetPoolIdFromName::TabStyle);
                     pTable->SetTableStyleName(sName);
                     SwDoc* pDoc = pFormat->GetDoc();
-                    
pDoc->GetDocShell()->GetFEShell()->UpdateTableStyleFormatting(pTable->GetTableNode());
+                    if (SwFEShell* pFEShell = 
pDoc->GetDocShell()->GetFEShell())
+                        
pFEShell->UpdateTableStyleFormatting(pTable->GetTableNode());
                 }
                 break;
 
diff --git a/sw/source/ui/vba/vbadocumentproperties.cxx 
b/sw/source/ui/vba/vbadocumentproperties.cxx
index 10ae56ab2d88..0e82611c926a 100644
--- a/sw/source/ui/vba/vbadocumentproperties.cxx
+++ b/sw/source/ui/vba/vbadocumentproperties.cxx
@@ -311,11 +311,8 @@ public:
         {
             if ( mpDocShell )
             {
-                SwFEShell* pFEShell = mpDocShell->GetFEShell();
-                if(pFEShell)
-                {
+                if (SwFEShell* pFEShell = mpDocShell->GetFEShell())
                     aReturn <<= pFEShell->GetLineCount();
-                }
             }
         }
         else
diff --git a/sw/source/ui/vba/vbaselection.cxx 
b/sw/source/ui/vba/vbaselection.cxx
index dde7d4e21fb5..4e471525425f 100644
--- a/sw/source/ui/vba/vbaselection.cxx
+++ b/sw/source/ui/vba/vbaselection.cxx
@@ -1104,11 +1104,8 @@ void SAL_CALL SwVbaSelection::SplitTable()
     SwDocShell* pDocShell = word::getDocShell( mxModel );
     if( pDocShell )
     {
-        SwFEShell* pFEShell = pDocShell->GetFEShell();
-        if( pFEShell )
-        {
+        if (SwFEShell* pFEShell = pDocShell->GetFEShell())
             pFEShell->SplitTable( SplitTable_HeadlineOption::ContentCopy );
-        }
     }
 }
 
diff --git a/sw/source/uibase/app/docst.cxx b/sw/source/uibase/app/docst.cxx
index 6ab7e659ae92..f624ff377ac6 100644
--- a/sw/source/uibase/app/docst.cxx
+++ b/sw/source/uibase/app/docst.cxx
@@ -1338,9 +1338,12 @@ void SwDocShell::UpdateStyle(const OUString &rName, 
SfxStyleFamily nFamily, SwWr
         break;
         case SfxStyleFamily::Table:
         {
-            if(GetFEShell()->IsTableMode())
+            if (SwFEShell* pFEShell = GetFEShell())
             {
-                GetFEShell()->TableCursorToCursor();
+                if(pFEShell->IsTableMode())
+                {
+                    pFEShell->TableCursorToCursor();
+                }
             }
             SwTableAutoFormat aFormat(rName);
             if (pCurrWrtShell->GetTableAutoFormat(aFormat))
diff --git a/sw/source/uibase/shells/textsh1.cxx 
b/sw/source/uibase/shells/textsh1.cxx
index 37b321383a55..e28877c91f17 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -643,7 +643,8 @@ void SwTextShell::Execute(SfxRequest &rReq)
             rWrtSh.ResetAttr( aAttribs );
 
             // also clear the direct formatting flag inside SwTableBox(es)
-            
GetView().GetDocShell()->GetFEShell()->UpdateTableStyleFormatting(nullptr, 
true);
+            if (SwFEShell* pFEShell = GetView().GetDocShell()->GetFEShell())
+                pFEShell->UpdateTableStyleFormatting(nullptr, true);
 
             rReq.Done();
             break;

Reply via email to