summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2020-06-18 18:32:24 +0200
committerAdolfo Jayme Barrientos <fitojb@ubuntu.com>2020-06-24 12:24:14 +0200
commit1532a477553ef87dd34693fad50028d6813d5007 (patch)
treea2d19a064a43d5c9bfc2bd73db6ec287d9e37c79
parent4c853820015849eb45ff21fe388eee6ec2565962 (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> (cherry picked from commit 57d488660572d62ef0371e50dcdd4ca7a6d98a14) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96634 Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> (cherry picked from commit 1d58ce59eb1ce7c9921a6827077349a9da315f78) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96807 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com> Tested-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
-rw-r--r--sw/source/core/docnode/ndsect.cxx5
-rw-r--r--sw/source/core/edit/eddel.cxx12
2 files changed, 15 insertions, 2 deletions
diff --git a/sw/source/core/docnode/ndsect.cxx b/sw/source/core/docnode/ndsect.cxx
index 8655874fe858..ef388242fa67 100644
--- a/sw/source/core/docnode/ndsect.cxx
+++ b/sw/source/core/docnode/ndsect.cxx
@@ -598,7 +598,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 162be4b48fff..10e471767998 100644
--- a/sw/source/core/edit/eddel.cxx
+++ b/sw/source/core/edit/eddel.cxx
@@ -101,7 +101,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();
}