[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - sc/source

Dennis Francis (via logerrit) logerrit at kemper.freedesktop.org
Mon Jul 5 10:59:09 UTC 2021


 sc/source/ui/docshell/docfunc.cxx |    3 ++-
 sc/source/ui/view/dbfunc3.cxx     |   10 ++++++++--
 sc/source/ui/view/viewdata.cxx    |    6 ++++--
 sc/source/ui/view/viewfunc.cxx    |   16 ++++++++++++----
 4 files changed, 26 insertions(+), 9 deletions(-)

New commits:
commit b302efec7bb3dbf1de3ef66c2f2098d6d69ba9aa
Author:     Dennis Francis <dennisfrancis.in at gmail.com>
AuthorDate: Fri Jul 2 19:01:47 2021 +0530
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Mon Jul 5 12:58:34 2021 +0200

    lok: sc: avoid crash on non existent tab view data
    
    ... when accessing position helpers.
    
    Change-Id: Ia627a8c4ed30ad1f1c2333df00b656fe041f111e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118318
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index 38af064a918c..15a57dc42400 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -161,7 +161,8 @@ bool ScDocFunc::AdjustRowHeight( const ScRange& rRange, bool bPaint )
             ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell);
             if (pTabViewShell)
             {
-                pTabViewShell->GetViewData().GetLOKHeightHelper(nTab)->invalidateByIndex(nStartRow);
+                if (ScPositionHelper* pPosHelper = pTabViewShell->GetViewData().GetLOKHeightHelper(nTab))
+                    pPosHelper->invalidateByIndex(nStartRow);
             }
             pViewShell = SfxViewShell::GetNext(*pViewShell);
         }
diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx
index d1f57b46dead..c7f7d81a8a9e 100644
--- a/sc/source/ui/view/dbfunc3.cxx
+++ b/sc/source/ui/view/dbfunc3.cxx
@@ -2260,9 +2260,15 @@ void ScDBFunc::OnLOKShowHideColRow(bool bColumns, SCCOLROW nStart)
         if (pTabViewShell)
         {
             if (bColumns)
-                pTabViewShell->GetViewData().GetLOKWidthHelper(nCurrentTabIndex)->invalidateByIndex(nStart);
+            {
+                if (ScPositionHelper* pPosHelper = pTabViewShell->GetViewData().GetLOKWidthHelper(nCurrentTabIndex))
+                    pPosHelper->invalidateByIndex(nStart);
+            }
             else
-                pTabViewShell->GetViewData().GetLOKHeightHelper(nCurrentTabIndex)->invalidateByIndex(nStart);
+            {
+                if (ScPositionHelper* pPosHelper = pTabViewShell->GetViewData().GetLOKHeightHelper(nCurrentTabIndex))
+                    pPosHelper->invalidateByIndex(nStart);
+            }
 
             if (pTabViewShell->getPart() == nCurrentTabIndex)
             {
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index 1c7e36ca484a..39f23fb31f62 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -1996,7 +1996,8 @@ void ScViewData::SetTabNo( SCTAB nNewTab )
 
 ScPositionHelper* ScViewData::GetLOKWidthHelper(SCTAB nTabIndex)
 {
-    if (!ValidTab(nTabIndex) || (nTabIndex >= static_cast<SCTAB>(maTabData.size())))
+    if (!ValidTab(nTabIndex) || (nTabIndex >= static_cast<SCTAB>(maTabData.size())) ||
+        !maTabData[nTabIndex])
     {
         return nullptr;
     }
@@ -2005,7 +2006,8 @@ ScPositionHelper* ScViewData::GetLOKWidthHelper(SCTAB nTabIndex)
 
 ScPositionHelper* ScViewData::GetLOKHeightHelper(SCTAB nTabIndex)
 {
-    if (!ValidTab(nTabIndex) || (nTabIndex >= static_cast<SCTAB>(maTabData.size())))
+    if (!ValidTab(nTabIndex) || (nTabIndex >= static_cast<SCTAB>(maTabData.size())) ||
+        !maTabData[nTabIndex])
     {
         return nullptr;
     }
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index a0e1185a6d3f..51738b4951af 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -1487,7 +1487,8 @@ void ScViewFunc::OnLOKInsertDeleteColumn(SCCOL nStartCol, long nOffset)
         ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell);
         if (pTabViewShell)
         {
-            pTabViewShell->GetViewData().GetLOKWidthHelper(nCurrentTabIndex)->invalidateByIndex(nStartCol);
+            if (ScPositionHelper* pPosHelper = pTabViewShell->GetViewData().GetLOKWidthHelper(nCurrentTabIndex))
+                pPosHelper->invalidateByIndex(nStartCol);
 
             // if we remove a column the cursor position  and the current selection
             // in other views could need to be moved on the left by one column.
@@ -1542,7 +1543,8 @@ void ScViewFunc::OnLOKInsertDeleteRow(SCROW nStartRow, long nOffset)
         ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell);
         if (pTabViewShell)
         {
-            pTabViewShell->GetViewData().GetLOKHeightHelper(nCurrentTabIndex)->invalidateByIndex(nStartRow);
+            if (ScPositionHelper* pPosHelper = pTabViewShell->GetViewData().GetLOKHeightHelper(nCurrentTabIndex))
+                pPosHelper->invalidateByIndex(nStartRow);
 
             // if we remove a row the cursor position and the current selection
             // in other views could need to be moved up by one row.
@@ -1598,9 +1600,15 @@ void ScViewFunc::OnLOKSetWidthOrHeight(SCCOLROW nStart, bool bWidth)
         if (pTabViewShell)
         {
             if (bWidth)
-                pTabViewShell->GetViewData().GetLOKWidthHelper(nCurTab)->invalidateByIndex(nStart);
+            {
+                if (ScPositionHelper* pPosHelper = pTabViewShell->GetViewData().GetLOKWidthHelper(nCurTab))
+                    pPosHelper->invalidateByIndex(nStart);
+            }
             else
-                pTabViewShell->GetViewData().GetLOKHeightHelper(nCurTab)->invalidateByIndex(nStart);
+            {
+                if (ScPositionHelper* pPosHelper = pTabViewShell->GetViewData().GetLOKHeightHelper(nCurTab))
+                    pPosHelper->invalidateByIndex(nStart);
+            }
         }
         pViewShell = SfxViewShell::GetNext(*pViewShell);
     }


More information about the Libreoffice-commits mailing list