diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-11-23 21:02:44 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-11-24 09:04:30 +0100 |
commit | 42e8e16cf93dcf944e5c1106f76aaa32057c0397 (patch) | |
tree | 3660dda4c1067fe64fc8b1026269edd00b76bd0a /sw/source | |
parent | e1b05b134e43d3186ddc5b8cfbbacb62ee4af483 (diff) |
tdf#138253 sw textbox: fix content of draw format on undo
Regression from commit da4f9b77a6cd39b1ae5babdd476d1575c8b9371c
(tdf#135149 sw: fix deleting textbox of as-char shapes, 2020-09-07), the
crash was caused by a user-after-free triggered from the X11 clipboard
code. This could happen beause the clipboard document had a draw frame
format, which has an SwNode pointer, but the SwNode instance was outside
that clipboard document, and the owning document is already gone. So by
the time the clipboard document would be deleted, the SwNodeIndex can't
de-register itself.
The root cause was that the doc model was corrupted after a cut of a
textbox + undo: the textbox pointers of the fly/draw formats were OK,
but not the SwFormatContent of the draw format.
Change-Id: I5761b72948caca397320aed801559e8493c33e1b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106453
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/core/layout/atrfrm.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/undo/undobj1.cxx | 7 |
2 files changed, 9 insertions, 0 deletions
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index 84076a24ced6..8755ee81235d 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -615,6 +615,8 @@ void SwFormatContent::dumpAsXml(xmlTextWriterPtr pWriter) const xmlTextWriterWriteAttribute( pWriter, BAD_CAST("startNode"), BAD_CAST(OString::number(m_pStartNode->GetNode().GetIndex()).getStr())); + xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("startNodePtr"), "%p", + &m_pStartNode->GetNode()); } xmlTextWriterEndElement(pWriter); } diff --git a/sw/source/core/undo/undobj1.cxx b/sw/source/core/undo/undobj1.cxx index 15801bca46e2..fb779e53d4f9 100644 --- a/sw/source/core/undo/undobj1.cxx +++ b/sw/source/core/undo/undobj1.cxx @@ -155,6 +155,13 @@ void SwUndoFlyBase::InsFly(::sw::UndoRedoContext & rContext, bool bShowSelFrame) pSdrObject->setUnoShape(nullptr); } } + if (m_pFrameFormat->Which() == RES_DRAWFRMFMT) + { + // This is a draw format and we just set the fly format's textbox pointer to this draw + // format. Sync the draw format's content with the fly format's content. + SwFrameFormat* pFlyFormat = m_pFrameFormat->GetOtherTextBoxFormat(); + m_pFrameFormat->SetFormatAttr(pFlyFormat->GetContent()); + } } m_pFrameFormat->MakeFrames(); |