diff options
author | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-03-29 10:00:30 +0000 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-03-29 20:35:00 +0100 |
commit | 18d0b7ac865f8d905a8b9afbe56677c89b1f406c (patch) | |
tree | 1ea8eb66ca3282ed6258c2f17b9827a0ff90c465 /sc/qa | |
parent | e94c6761260ae30f1e4b91d65f8a5493dc8a3140 (diff) |
Resolves: tdf#160368 crash on save after deleting sheet
to reproduce the underlying problem: data, calc, recalculate hard:
which asserts that cell I367 is dirty during parallel calc
checking the dependencies for a parallel calc is supposed to find what
cells it depends on and either: ensure they are not dirty or detect its
not possible to do the parallel calc
checking starts in J9 where::
J9: =SUM(H$8:H9)-SUM(I9:I$9)
J10 =SUM(H$8:H10)-SUM(I10:I$9)
for the first sum it detects that the input range is H9:H367 and checks
that for dirty results, but for the second sum it detects a range of
just I9 and the dirty I367 is not detected and the problem arises on
calculation
The code to detect the range is:
// The first row that will be referenced through the doubleref.
SCROW nFirstRefRow = bIsRef1RowRel ? aAbs.aStart.Row() + mnStartOffset : aAbs.aStart.Row();
// The last row that will be referenced through the doubleref.
SCROW nLastRefRow = bIsRef2RowRel ? aAbs.aEnd.Row() + mnEndOffset : aAbs.aEnd.Row();
where for the I9 case has nFirstRefRow true and nLastRefRow false so we
just get a range of I9:I9 instead of I9:I367.
Trying to create a doc from scratch to reproduce this case proves
tricky, so trim down the original document to the sheet and subset
of columns that can trigger it.
Change-Id: I44bfd1f6d3a3ee13db9024c5b2efa2588cc30521
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165510
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'sc/qa')
-rw-r--r-- | sc/qa/unit/data/ods/tdf160368.ods | bin | 0 -> 25405 bytes | |||
-rw-r--r-- | sc/qa/unit/parallelism.cxx | 88 | ||||
-rw-r--r-- | sc/qa/unit/ucalc_parallelism.cxx | 3 |
3 files changed, 91 insertions, 0 deletions
diff --git a/sc/qa/unit/data/ods/tdf160368.ods b/sc/qa/unit/data/ods/tdf160368.ods Binary files differnew file mode 100644 index 000000000000..f9da81d27846 --- /dev/null +++ b/sc/qa/unit/data/ods/tdf160368.ods diff --git a/sc/qa/unit/parallelism.cxx b/sc/qa/unit/parallelism.cxx new file mode 100644 index 000000000000..0ced71c44228 --- /dev/null +++ b/sc/qa/unit/parallelism.cxx @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <sal/config.h> + +#include "helper/qahelper.hxx" + +#include <document.hxx> +#include <formulagroup.hxx> + +#include <officecfg/Office/Calc.hxx> + +using namespace sc; + +// test-suite suitable for loading documents to test parallelism in +// with access only to exported symbols + +class ScParallelismTest : public ScModelTestBase +{ +public: + ScParallelismTest() + : ScModelTestBase("sc/qa/unit/data") + { + } + + virtual void setUp() override; + virtual void tearDown() override; + +private: + bool getThreadingFlag() const; + void setThreadingFlag(bool bSet); + + bool m_bThreadingFlagCfg; +}; + +bool ScParallelismTest::getThreadingFlag() const +{ + return officecfg::Office::Calc::Formula::Calculation::UseThreadedCalculationForFormulaGroups:: + get(); +} + +void ScParallelismTest::setThreadingFlag(bool bSet) +{ + std::shared_ptr<comphelper::ConfigurationChanges> xBatch( + comphelper::ConfigurationChanges::create()); + officecfg::Office::Calc::Formula::Calculation::UseThreadedCalculationForFormulaGroups::set( + bSet, xBatch); + xBatch->commit(); +} + +void ScParallelismTest::setUp() +{ + ScModelTestBase::setUp(); + + sc::FormulaGroupInterpreter::disableOpenCL_UnitTestsOnly(); + + m_bThreadingFlagCfg = getThreadingFlag(); + if (!m_bThreadingFlagCfg) + setThreadingFlag(true); +} + +void ScParallelismTest::tearDown() +{ + // Restore threading flag + if (!m_bThreadingFlagCfg) + setThreadingFlag(false); + + ScModelTestBase::tearDown(); +} + +// Dependency range in this document was detected as I9:I9 instead of expected I9:I367 +CPPUNIT_TEST_FIXTURE(ScParallelismTest, testTdf160368) +{ + createScDoc("ods/tdf160368.ods"); + ScDocShell* pDocSh = getScDocShell(); + // without fix: ScFormulaCell::MaybeInterpret(): Assertion `!rDocument.IsThreadedGroupCalcInProgress()' failed. + pDocSh->DoHardRecalc(); +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/sc/qa/unit/ucalc_parallelism.cxx b/sc/qa/unit/ucalc_parallelism.cxx index 56b849b8e058..04f17f383ede 100644 --- a/sc/qa/unit/ucalc_parallelism.cxx +++ b/sc/qa/unit/ucalc_parallelism.cxx @@ -16,6 +16,9 @@ using namespace css; using namespace css::uno; +// test-suite suitable for creating documents to test parallelism in +// with access to internal unexported symbols + class ScParallelismTest : public ScUcalcTestBase { public: |