sw/qa/uitest/data/tdf146248.docx |binary sw/qa/uitest/writer_tests4/insertPageHeader.py | 14 ++++++++++++++ sw/source/core/unocore/unoobj2.cxx | 3 +++ 3 files changed, 17 insertions(+)
New commits: commit d1ddaa59ad34f1f5f6fcd46ad63cc432e0d01b52 Author: László Németh <nem...@numbertext.org> AuthorDate: Mon Jan 9 15:07:27 2023 +0100 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Thu Jan 26 13:19:24 2023 +0000 tdf#146248 sw: fix crash at Undo of hiding page header/footer When Same content on first page is enabled, Undo could result crashing after hiding header/footer with its local menu. Note: the problem could occur in DOCX more frequently, because of special handling of its header/footer, see commit f5dc6b11d2218d94c9effe7a1ab418d0133da5e3 "tdf#140117 sw UI: keep headers/footers when inactive". Manual test: load the unit test document, delete the header with its blue local menu (not with the Page Style dialog window!), and press Undo. (The Python UITest does the same, but with dispatcher calls). Regression from commit 65e52cb61d74b0c71b45b63b2da131bc6b621104 "tdf#141613 sw: fix crash at header/footer undo". Change-Id: If89d5af2e0d123d6913dfc6a4bea1ddbaf3bd80b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145244 Tested-by: László Németh <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> (cherry picked from commit cec3c719303decd3b811a328fabd71d8c4e5ba3b) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145300 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> (cherry picked from commit c617aafc370209b8807ba6e0eba2762595595a0f) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146092 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sw/qa/uitest/data/tdf146248.docx b/sw/qa/uitest/data/tdf146248.docx new file mode 100644 index 000000000000..2b5ed2959f94 Binary files /dev/null and b/sw/qa/uitest/data/tdf146248.docx differ diff --git a/sw/qa/uitest/writer_tests4/insertPageHeader.py b/sw/qa/uitest/writer_tests4/insertPageHeader.py index b18efd74241a..9da58db9a2b2 100644 --- a/sw/qa/uitest/writer_tests4/insertPageHeader.py +++ b/sw/qa/uitest/writer_tests4/insertPageHeader.py @@ -8,6 +8,7 @@ # from uitest.framework import UITestCase +from uitest.uihelper.common import get_url_for_data_file class WriterInsertPageHeader(UITestCase): @@ -61,4 +62,17 @@ class WriterInsertPageHeader(UITestCase): self.delete_header() + def test_tdf146248(self): + with self.ui_test.load_file(get_url_for_data_file("tdf146248.docx")): + + self.delete_header() + + # crashed before + self.xUITest.executeCommand(".uno:Undo") + + document = self.ui_test.get_component() + self.assertEqual( + document.StyleFamilies.PageStyles.Standard.HeaderIsOn, True) + + # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 1bfe4fae6ae3..ddf4cca6961c 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -1195,6 +1195,9 @@ lcl_IsStartNodeInFormat(const bool bHeader, SwStartNode const *const pSttNode, if (pHeadFootFormat) { const SwFormatContent& rFlyContent = pHeadFootFormat->GetContent(); + // tdf#146248 avoid Undo crash at shared first page + if ( !rFlyContent.GetContentIdx() ) + return false; const SwNode& rNode = rFlyContent.GetContentIdx()->GetNode(); SwStartNode const*const pCurSttNode = rNode.FindSttNodeByType( bHeader ? SwHeaderStartNode : SwFooterStartNode);