diff options
author | László Németh <nemeth@numbertext.org> | 2023-01-09 15:07:27 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2023-01-11 16:07:57 +0000 |
commit | c617aafc370209b8807ba6e0eba2762595595a0f (patch) | |
tree | bbdb972d93475caffb0df1f789c111e86608cb8a | |
parent | Fix deprecated Curl elements for minidump part (diff) | |
download | core-c617aafc370209b8807ba6e0eba2762595595a0f.tar.gz core-c617aafc370209b8807ba6e0eba2762595595a0f.zip |
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 <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
(cherry picked from commit cec3c719303decd3b811a328fabd71d8c4e5ba3b)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145300
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | sw/qa/uitest/data/tdf146248.docx | bin | 0 -> 11387 bytes | |||
-rw-r--r-- | sw/qa/uitest/writer_tests4/insertPageHeader.py | 14 | ||||
-rw-r--r-- | sw/source/core/unocore/unoobj2.cxx | 3 |
3 files changed, 17 insertions, 0 deletions
diff --git a/sw/qa/uitest/data/tdf146248.docx b/sw/qa/uitest/data/tdf146248.docx Binary files differnew file mode 100644 index 000000000000..2b5ed2959f94 --- /dev/null +++ b/sw/qa/uitest/data/tdf146248.docx diff --git a/sw/qa/uitest/writer_tests4/insertPageHeader.py b/sw/qa/uitest/writer_tests4/insertPageHeader.py index 6516a31dab4d..406671021881 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 538ea72430b0..e5fefbc0e376 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -1191,6 +1191,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); |