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

Dennis Francis (via logerrit) logerrit at kemper.freedesktop.org
Fri Aug 6 08:25:15 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 4f80254855f05fc95829b841f09a39f6aa613248
Author:     Dennis Francis <dennisfrancis.in at gmail.com>
AuthorDate: Fri Jul 2 19:01:47 2021 +0530
Commit:     Dennis Francis <dennis.francis at collabora.com>
CommitDate: Fri Aug 6 10:24:19 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/+/119601
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index 3a135d9d0042..40a19baecaa5 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -167,7 +167,8 @@ bool ScDocFunc::AdjustRowHeight( const ScRange& rRange, bool bPaint, bool bApi )
                 ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell);
                 if (pTabViewShell && pTabViewShell->GetDocId() == pSomeViewForThisDoc->GetDocId())
                 {
-                    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 52942816c138..424d416fdd4f 100644
--- a/sc/source/ui/view/dbfunc3.cxx
+++ b/sc/source/ui/view/dbfunc3.cxx
@@ -2274,9 +2274,15 @@ void ScDBFunc::OnLOKShowHideColRow(bool bColumns, SCCOLROW nStart)
         if (pTabViewShell && pTabViewShell->GetDocId() == pThisViewShell->GetDocId())
         {
             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 6b735e21130c..e4b0af86df85 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -2273,7 +2273,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;
     }
@@ -2282,7 +2283,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 774f3a27aa26..08f8ac2f8ce2 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -1479,7 +1479,8 @@ void ScViewFunc::OnLOKInsertDeleteColumn(SCCOL nStartCol, long nOffset)
         ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell);
         if (pTabViewShell && pTabViewShell->GetDocId() == pCurrentViewShell->GetDocId())
         {
-            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.
@@ -1535,7 +1536,8 @@ void ScViewFunc::OnLOKInsertDeleteRow(SCROW nStartRow, long nOffset)
         ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell);
         if (pTabViewShell && pTabViewShell->GetDocId() == pCurrentViewShell->GetDocId())
         {
-            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.
@@ -1592,9 +1594,15 @@ void ScViewFunc::OnLOKSetWidthOrHeight(SCCOLROW nStart, bool bWidth)
         if (pTabViewShell && pTabViewShell->GetDocId() == pCurrentViewShell->GetDocId())
         {
             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