sw/source/uibase/shells/textfld.cxx |    4 ++++
 1 file changed, 4 insertions(+)

New commits:
commit ee0d856d921afc826ea8a48b82d489be7b45bc3d
Author:     Justin Luth <jl...@mail.com>
AuthorDate: Fri Jul 19 09:50:11 2024 -0400
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Thu Sep 5 08:22:17 2024 +0200

    tdf#161741 tdf#161705 pgnum wizard: avoid undo crash (sledgehammer)
    
    This was fixed differently (hopefully more elegantly) in master,
    but that patch cannot be confidently backported.
    So this alternate approach is proposed for backport to stable.
    
    The "kill undo completely" approach
    that this patch is reverting back too is still commonly used for
    anything-to-do-with-page-style-headers-and-footers.
    
    i.e sw/source/core/unocore/unostyle.cxx // Fix i64460: as long as
      Undo of page styles with header/footer causes trouble...
    
    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/+/172822
    Reviewed-by: Justin Luth <jl...@mail.com>
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/source/uibase/shells/textfld.cxx 
b/sw/source/uibase/shells/textfld.cxx
index b9e12c45a384..187129190133 100644
--- a/sw/source/uibase/shells/textfld.cxx
+++ b/sw/source/uibase/shells/textfld.cxx
@@ -1365,6 +1365,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();
         });

Reply via email to