sc/source/core/data/column2.cxx     |    9 +++++++++
 sc/source/core/data/formulacell.cxx |   15 +++++++++++++++
 2 files changed, 24 insertions(+)

New commits:
commit 12f00988c2360713885ecf7eb4b643dd118cd051
Author:     Luboš Luňák <[email protected]>
AuthorDate: Wed Nov 7 15:35:26 2018 +0100
Commit:     Luboš Luňák <[email protected]>
CommitDate: Wed Nov 14 16:10:02 2018 +0100

    make sure ScConditionEntry::Interpret() doesn't confuse calc threading
    
    ScConditionEntry::Interpret() creates a temporary cell and interprets it
    without it actually being in the document at the specified position,
    which threading relies upon.
    
    Change-Id: I06fcc11dfbe14e715de4c173e061064ac90da990
    Reviewed-on: https://gerrit.libreoffice.org/63182
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <[email protected]>

diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 93bcf9bd6531..a4078e75427d 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -2902,8 +2902,11 @@ void ScColumn::SetFormulaResults( SCROW nRow, const 
double* pResults, size_t nLe
     sc::CellStoreType::position_type aPos = maCells.position(nRow);
     sc::CellStoreType::iterator it = aPos.first;
     if (it->type != sc::element_type_formula)
+    {
         // This is not a formula block.
+        assert( false );
         return;
+    }
 
     size_t nBlockLen = it->size - aPos.second;
     if (nBlockLen < nLen)
@@ -2934,8 +2937,11 @@ void ScColumn::CalculateInThread( ScInterpreterContext& 
rContext, SCROW nRow, si
     sc::CellStoreType::position_type aPos = maCells.position(nRow);
     sc::CellStoreType::iterator it = aPos.first;
     if (it->type != sc::element_type_formula)
+    {
         // This is not a formula block.
+        assert( false );
         return;
+    }
 
     size_t nBlockLen = it->size - aPos.second;
     if (nBlockLen < nLen)
@@ -2962,8 +2968,11 @@ void ScColumn::HandleStuffAfterParallelCalculation( 
SCROW nRow, size_t nLen )
     sc::CellStoreType::position_type aPos = maCells.position(nRow);
     sc::CellStoreType::iterator it = aPos.first;
     if (it->type != sc::element_type_formula)
+    {
         // This is not a formula block.
+        assert( false );
         return;
+    }
 
     size_t nBlockLen = it->size - aPos.second;
     if (nBlockLen < nLen)
diff --git a/sc/source/core/data/formulacell.cxx 
b/sc/source/core/data/formulacell.cxx
index 8d16fdf0d352..6d284ff43dbf 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -4523,6 +4523,21 @@ bool ScFormulaCell::InterpretFormulaGroup()
         return false;
     }
 
+    if( forceType != ForceCalculationNone )
+    {
+        // ScConditionEntry::Interpret() creates a temporary cell and 
interprets it
+        // without it actually being in the document at the specified position.
+        // That would confuse opencl/threading code, as they refer to the cell 
group
+        // also using the position. This is normally not triggered (single 
cells
+        // are normally not in a cell group), but if forced, check for this 
explicitly.
+        if( pDocument->GetFormulaCell( aPos ) != this )
+        {
+            mxGroup->meCalcState = sc::GroupCalcDisabled;
+            aScope.addMessage("cell not in document");
+            return false;
+        }
+    }
+
     // Guard against endless recursion of Interpret() calls, for this to work
     // ScFormulaCell::InterpretFormulaGroup() must never be called through
     // anything else than ScFormulaCell::Interpret(), same as
_______________________________________________
Libreoffice-commits mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to