summaryrefslogtreecommitdiff
path: root/sc/qa
diff options
context:
space:
mode:
authorAttila Szűcs <szucs.attila3@nisz.hu>2022-06-22 14:43:04 +0200
committerLászló Németh <nemeth@numbertext.org>2022-06-23 15:34:02 +0200
commit954d119db932434dc976ef739c643be0d9c7023c (patch)
treea5f908f31870db26ce2f8957adf6b708d30e8155 /sc/qa
parenta2fad16357309f1eba4346dc826bc5ad7012b1aa (diff)
tdf#149502 sc: crash fix: Change in Table destruction
Postpone ScTable destruction a bit, when ScTable::nTab is synchronized with ScDocument::maTabs[] to avoid crashing. Before the fix random crashing occurred if the ScTable::nTab was already updated when ~ScTable() called, but the ScDocument::maTabs[] was not reordered yet, so nTab could have pointed to the actually deleted table in mTabs[]. Co-authored-by: Tibor Nagy (NISZ) Change-Id: I2ac1450e3483ab334b4e20ac2598c2191e0135c9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136284 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sc/qa')
-rw-r--r--sc/qa/unit/uicalc/data/tdf149502_HangOnDeletingSheet1.odsbin0 -> 28020 bytes
-rw-r--r--sc/qa/unit/uicalc/uicalc.cxx17
2 files changed, 17 insertions, 0 deletions
diff --git a/sc/qa/unit/uicalc/data/tdf149502_HangOnDeletingSheet1.ods b/sc/qa/unit/uicalc/data/tdf149502_HangOnDeletingSheet1.ods
new file mode 100644
index 000000000000..e34a75c32308
--- /dev/null
+++ b/sc/qa/unit/uicalc/data/tdf149502_HangOnDeletingSheet1.ods
Binary files differ
diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx
index a6f648ce9766..2e48f42f2e73 100644
--- a/sc/qa/unit/uicalc/uicalc.cxx
+++ b/sc/qa/unit/uicalc/uicalc.cxx
@@ -1512,6 +1512,23 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf86166)
CPPUNIT_ASSERT_EQUAL(static_cast<SCTAB>(1), pDoc->GetTableCount());
}
+CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf149502_HangOnDeletingSheet1)
+{
+ ScModelObj* pModelObj = createDoc("tdf149502_HangOnDeletingSheet1.ods");
+ ScDocument* pDoc = pModelObj->GetDocument();
+ CPPUNIT_ASSERT(pDoc);
+
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCTAB>(4), pDoc->GetTableCount());
+
+ uno::Sequence<beans::PropertyValue> aArgs(
+ comphelper::InitPropertySequence({ { "Index", uno::Any(sal_uInt16(0)) } }));
+
+ // Before the fix in place, this test frozen here
+ dispatchCommand(mxComponent, ".uno:Remove", aArgs);
+
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCTAB>(3), pDoc->GetTableCount());
+}
+
CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf149503)
{
ScModelObj* pModelObj = createDoc("tdf149503.xls");