diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2021-03-08 22:50:58 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2021-03-09 11:12:25 +0100 |
commit | 2fb274950e5207ca55f4f52325fb522bd44024e1 (patch) | |
tree | 4363b96e98767ff373afe6df8ccbc765fea03158 | |
parent | 862fd2fa19b64972247bde9b171ec828a30e1676 (diff) |
fix ScFlatBoolSegmentsImpl delayed setup with threads (tdf#140754)
Change-Id: I258263f6a15e7098a2292ba7f3336fcaaf5224ff
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112184
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
-rw-r--r-- | sc/inc/segmenttree.hxx | 9 | ||||
-rw-r--r-- | sc/source/core/data/segmenttree.cxx | 32 | ||||
-rw-r--r-- | sc/source/core/data/table1.cxx | 5 |
3 files changed, 46 insertions, 0 deletions
diff --git a/sc/inc/segmenttree.hxx b/sc/inc/segmenttree.hxx index 58e59e60cd84..7e25d232a03f 100644 --- a/sc/inc/segmenttree.hxx +++ b/sc/inc/segmenttree.hxx @@ -77,6 +77,9 @@ public: SCROW findLastTrue() const; + // Builds internal data (so that it doesn't build them while used in threads). + void makeReady(); + OString dumpAsString(); private: @@ -102,6 +105,9 @@ public: void removeSegment(SCCOL nCol1, SCCOL nCol2); void insertSegment(SCCOL nCol, SCCOL nSize); + // Builds internal data (so that it doesn't build them while used in threads). + void makeReady(); + OString dumpAsString(); private: @@ -153,6 +159,9 @@ public: void enableTreeSearch(bool bEnable); + // Builds internal data (so that it doesn't build them while used in threads). + void makeReady(); + OString dumpAsString(); private: diff --git a/sc/source/core/data/segmenttree.cxx b/sc/source/core/data/segmenttree.cxx index 4ccf146a01c3..d73d233d894c 100644 --- a/sc/source/core/data/segmenttree.cxx +++ b/sc/source/core/data/segmenttree.cxx @@ -23,6 +23,7 @@ #include <sal/log.hxx> #include <algorithm> #include <limits> +#include <global.hxx> using ::std::numeric_limits; @@ -65,6 +66,8 @@ public: mbTreeSearchEnabled = b; } + void makeReady(); + private: typedef ::mdds::flat_segment_tree<SCCOLROW, ValueType> fst_type; fst_type maSegments; @@ -130,7 +133,10 @@ typename ScFlatSegmentsImpl<ValueType_, ExtValueType_>::ValueType ScFlatSegments } if (!maSegments.is_tree_valid()) + { + assert(!ScGlobal::bThreadedGroupCalcInProgress); maSegments.build_tree(); + } maSegments.search_tree(nPos, nValue); return nValue; @@ -184,7 +190,10 @@ bool ScFlatSegmentsImpl<ValueType_, ExtValueType_>::getRangeData(SCCOLROW nPos, return getRangeDataLeaf(nPos, rData); if (!maSegments.is_tree_valid()) + { + assert(!ScGlobal::bThreadedGroupCalcInProgress); maSegments.build_tree(); + } if (!maSegments.search_tree(nPos, rData.mnValue, &rData.mnPos1, &rData.mnPos2).second) return false; @@ -266,6 +275,14 @@ bool ScFlatSegmentsImpl<ValueType_, ExtValueType_>::getNext(RangeData& rData) return true; } +template<typename ValueType_, typename ExtValueType_> +void ScFlatSegmentsImpl<ValueType_, ExtValueType_>::makeReady() +{ + assert(!ScGlobal::bThreadedGroupCalcInProgress); + if (!maSegments.is_tree_valid()) + maSegments.build_tree(); +} + class ScFlatUInt16SegmentsImpl : public ScFlatSegmentsImpl<sal_uInt16, sal_uInt32> { public: @@ -415,6 +432,11 @@ SCROW ScFlatBoolRowSegments::findLastTrue() const return mpImpl->findLastTrue(false); } +void ScFlatBoolRowSegments::makeReady() +{ + mpImpl->makeReady(); +} + OString ScFlatBoolRowSegments::dumpAsString() { OString aOutput; @@ -482,6 +504,11 @@ void ScFlatBoolColSegments::insertSegment(SCCOL nCol, SCCOL nSize) mpImpl->insertSegment(static_cast<SCCOLROW>(nCol), static_cast<SCCOLROW>(nSize), true/*bSkipStartBoundary*/); } +void ScFlatBoolColSegments::makeReady() +{ + mpImpl->makeReady(); +} + OString ScFlatBoolColSegments::dumpAsString() { OString aOutput; @@ -595,6 +622,11 @@ void ScFlatUInt16RowSegments::setValueIf(SCROW nRow1, SCROW nRow2, sal_uInt16 nV mpImpl->setValueIf(static_cast<SCCOLROW>(nRow1), static_cast<SCCOLROW>(nRow2), nValue, rPredicate); } +void ScFlatUInt16RowSegments::makeReady() +{ + mpImpl->makeReady(); +} + OString ScFlatUInt16RowSegments::dumpAsString() { OString aOutput; diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx index 459f804984ed..f018bfc03d4d 100644 --- a/sc/source/core/data/table1.cxx +++ b/sc/source/core/data/table1.cxx @@ -2484,6 +2484,11 @@ bool ScTable::HandleRefArrayForParallelism( SCCOL nCol, SCROW nRow1, SCROW nRow2 if ( !IsColValid( nCol ) || !ValidRow( nRow1 ) || !ValidRow( nRow2 ) ) return false; + mpHiddenCols->makeReady(); + mpHiddenRows->makeReady(); + mpFilteredCols->makeReady(); + mpFilteredRows->makeReady(); + return aCol[nCol].HandleRefArrayForParallelism(nRow1, nRow2, mxGroup); } |