sw/qa/uitest/writer_tests3/pageNumber.py | 9 +++++---- sw/source/uibase/shells/textfld.cxx | 4 ++++ 2 files changed, 9 insertions(+), 4 deletions(-)
New commits: commit f84369daa125717f3c87fe34abb0b91c6f6ba3d5 Author: Justin Luth <jl...@mail.com> AuthorDate: Fri Jul 19 09:50:11 2024 -0400 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Fri May 2 15:08:56 2025 +0200 tdf#164033 tdf#161741 tdf#161705 pgnum wizard: avoid undo crash (sledgehammer) I have zero knowledge of the many intricate pitfalls of undo/redo, so there is no way I could create a "proper" fix. LO 7.6 introduced the page number wizard which has more prominently exposed existing ways to make undo/redo of page style changes to crash. So treat this as pre-LO 7.2 and simply erase the undo stack after running the wizard. ------------------------------------------------------------------ The ability to undo/redo the "Header/footer change" started in bibisect-linux-64-7.2 commit 910d9a081daf11ea53235d227c3dc9623942a824 commit 8d8486f43c1a8a51157bfc3e0b87090b05a9229e Author: Daniel Arato (NISZ) on Mon Feb 22 16:59:38 2021 +0100 tdf#46561 sw: fix lost undo stack setting header/footer - if( bHeaderFooterChanged ) - GetIDocumentUndoRedo().DelAllUndoObj(); Change-Id: I00c529784bfd7b2cd1230474c05eea8516e6c1e3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170771 Tested-by: Jenkins Tested-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sw/qa/uitest/writer_tests3/pageNumber.py b/sw/qa/uitest/writer_tests3/pageNumber.py index 27db67b753d3..af0cbe340067 100644 --- a/sw/qa/uitest/writer_tests3/pageNumber.py +++ b/sw/qa/uitest/writer_tests3/pageNumber.py @@ -43,7 +43,8 @@ class PageNumberWizard(UITestCase): self.xUITest.executeCommand(".uno:Undo") self.assertIsNone(document.StyleFamilies.PageStyles.Standard.HeaderText) - self.assertIsNone(document.StyleFamilies.PageStyles.Standard.FooterText) + # FIXME: tdf#164033: Undo is disabled to avoid the crash + self.assertIsNotNone(document.StyleFamilies.PageStyles.Standard.FooterText) with self.ui_test.execute_dialog_through_command(".uno:PageNumberWizard") as xDialog: xPositionCombo = xDialog.getChild("positionCombo") @@ -53,11 +54,11 @@ class PageNumberWizard(UITestCase): xHeader = document.StyleFamilies.PageStyles.Standard.HeaderText.createEnumeration().nextElement() self.assertEqual("A", xHeader.String) - self.assertIsNone(document.StyleFamilies.PageStyles.Standard.FooterText) + self.assertIsNotNone(document.StyleFamilies.PageStyles.Standard.FooterText) self.xUITest.executeCommand(".uno:Undo") - self.assertIsNone(document.StyleFamilies.PageStyles.Standard.HeaderText) - self.assertIsNone(document.StyleFamilies.PageStyles.Standard.FooterText) + self.assertIsNotNone(document.StyleFamilies.PageStyles.Standard.HeaderText) + self.assertIsNotNone(document.StyleFamilies.PageStyles.Standard.FooterText) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/source/uibase/shells/textfld.cxx b/sw/source/uibase/shells/textfld.cxx index 714a59611b99..34b0f464a48a 100644 --- a/sw/source/uibase/shells/textfld.cxx +++ b/sw/source/uibase/shells/textfld.cxx @@ -1489,6 +1489,10 @@ FIELD_INSERT: rSh.EndAllAction(); rSh.LockView(false); rDoc.GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT_PAGE_NUMBER, nullptr); + + // avoid various ways to crash related to undo of SwPageDesc (tdf#161741, tdf#161705) + if (bChangePageDesc) + rDoc.GetIDocumentUndoRedo().DelAllUndoObj(); } pDlg->disposeOnce(); });