diff options
author | Michael Stahl <Michael.Stahl@cib.de> | 2020-06-18 18:32:24 +0200 |
---|---|---|
committer | Michael Stahl <michael.stahl@cib.de> | 2020-06-18 20:18:00 +0200 |
commit | 57d488660572d62ef0371e50dcdd4ca7a6d98a14 (patch) | |
tree | 694e7163397de1a4f8364a0ac6ba181e9ddadda5 | |
parent | 5d836621326c68decaae09f1911d2d036a251b43 (diff) |
tdf#133990 sw_redlinehide: fix Undo with section before table
... at start of document.
The section node wasn't included in the PaM passed to SwUndoDelete,
so on Undo it called MakeFrames() starting from the contained table
node and crashed when reaching the section's end node.
Fixed, then it crashes in Redo, because SwDoc::DelSectionFormat()
calls SetModified() which calls some event listener which causes
EndAllAction() to be called, which by itself is scary and then it
crashes because the nodes array contains a bunch of deleted nodes.
Not sure if that SetModified() serves any purpose, but it's pointless
in Undo.
(1st crash is regression from 68880a3004623553bf1920ad8a4a4d2be4bca234)
Change-Id: Iafdd073ca9577bf54dd5a8ad2eb8f8f110db93b6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96620
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@cib.de>
-rw-r--r-- | sw/source/core/docnode/ndsect.cxx | 5 | ||||
-rw-r--r-- | sw/source/core/edit/eddel.cxx | 12 |
2 files changed, 15 insertions, 2 deletions
diff --git a/sw/source/core/docnode/ndsect.cxx b/sw/source/core/docnode/ndsect.cxx index 1c08f9ecbdc9..1c85a27a4853 100644 --- a/sw/source/core/docnode/ndsect.cxx +++ b/sw/source/core/docnode/ndsect.cxx @@ -601,7 +601,10 @@ void SwDoc::DelSectionFormat( SwSectionFormat *pFormat, bool bDelNodes ) GetIDocumentUndoRedo().EndUndo(SwUndoId::DELSECTION, nullptr); - getIDocumentState().SetModified(); + if (GetIDocumentUndoRedo().DoesUndo()) + { // TODO is this ever needed? + getIDocumentState().SetModified(); + } } void SwDoc::UpdateSection( size_t const nPos, SwSectionData & rNewData, diff --git a/sw/source/core/edit/eddel.cxx b/sw/source/core/edit/eddel.cxx index 59cc573216ee..b501833fc16d 100644 --- a/sw/source/core/edit/eddel.cxx +++ b/sw/source/core/edit/eddel.cxx @@ -99,7 +99,17 @@ void SwEditShell::DeleteSel( SwPaM& rPam, bool* pUndo ) pNewPam.reset(new SwPaM(*rPam.GetMark(), *rPam.GetPoint())); // Selection starts at the first para of the first cell, but we // want to delete the table node before the first cell as well. - pNewPam->Start()->nNode = pNewPam->Start()->nNode.GetNode().FindTableNode()->GetIndex(); + while (SwTableNode const* pTableNode = + pNewPam->Start()->nNode.GetNode().StartOfSectionNode()->FindTableNode()) + { + pNewPam->Start()->nNode = *pTableNode; + } + // tdf#133990 ensure section is included in SwUndoDelete + while (SwSectionNode const* pSectionNode = + pNewPam->Start()->nNode.GetNode().StartOfSectionNode()->FindSectionNode()) + { + pNewPam->Start()->nNode = *pSectionNode; + } pNewPam->Start()->nContent.Assign(nullptr, 0); pPam = pNewPam.get(); } |