sc/source/ui/unoobj/docuno.cxx |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

New commits:
commit 39ffd246450cbf5feb68d7f5ab058b92a951066a
Author:     Michael Meeks <michael.me...@collabora.com>
AuthorDate: Thu Dec 15 18:32:59 2022 +0000
Commit:     Michael Meeks <michael.me...@collabora.com>
CommitDate: Fri Dec 16 16:55:21 2022 +0000

    lok: protect sc from null ScViewData.
    
    Working hypothesis is this happens after a failed spreadsheet
    load, or from a race during load.
    
    <crash>
    ScModelObj::getPartInfo(int) sc/source/ui/unoobj/docuno.cxx:602
    doc_getPartInfo desktop/source/lib/init.cxx:3531
    ...
    KitSocketPoll::kitPoll(int)   coolforkit
    SvpSalInstance::DoYield(bool, bool) vcl/headless/svpinst.cxx:492
    
    Change-Id: I06870336d4e64ebfc69bce64e280821c25e1b1e1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144308
    Tested-by: Jenkins
    Reviewed-by: Michael Meeks <michael.me...@collabora.com>

diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index d3cbd98af592..9072d2824ce4 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -568,7 +568,10 @@ void ScModelObj::paintTile( VirtualDevice& rDevice,
 void ScModelObj::setPart( int nPart, bool /*bAllowChangeFocus*/ )
 {
     ScViewData* pViewData = ScDocShell::GetViewData();
-    ScTabView* pTabView = pViewData->GetView();
+    ScTabView* pTabView = nullptr;
+
+    if (pViewData)
+        pTabView = pViewData->GetView();
 
     if (pTabView)
     {
@@ -595,6 +598,8 @@ int ScModelObj::getPart()
 OUString ScModelObj::getPartInfo( int nPart )
 {
     ScViewData* pViewData = ScDocShell::GetViewData();
+    if (!pViewData)
+        return OUString();
     const bool bIsVisible = pViewData->GetDocument().IsVisible(nPart);
     //FIXME: Implement IsSelected().
     const bool bIsSelected = false; 
//pViewData->GetDocument()->IsSelected(nPart);
@@ -614,6 +619,8 @@ OUString ScModelObj::getPartName( int nPart )
 {
     OUString sTabName;
     ScViewData* pViewData = ScDocShell::GetViewData();
+    if (!pViewData)
+        return OUString();
     pViewData->GetDocument().GetName(nPart, sTabName);
     return sTabName;
 }
@@ -622,6 +629,8 @@ OUString ScModelObj::getPartHash( int nPart )
 {
     sal_Int64 nHashCode;
     ScViewData* pViewData = ScDocShell::GetViewData();
+    if (!pViewData)
+        return OUString();
     return (pViewData->GetDocument().GetHashCode(nPart, nHashCode) ? 
OUString::number(nHashCode) : OUString());
 }
 

Reply via email to