diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2021-09-14 13:46:53 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2021-09-14 15:34:55 +0200 |
commit | 2bf269745bed9fefe32122fc432e239949bdf605 (patch) | |
tree | efc75cf7bacfebd9cc33c4dac8844f9d6408696d /svx | |
parent | 6bf771f0a5ba7be9955f05b307c190fb157adb47 (diff) |
sw: fix undo manager de-registration from editeng on shutdown
editeng/ asserts in the ImpEditEngine dtor that the undo manager it owns
is indeed an EditUndoManager, and not a subclass. This means that if a
subclass is set as the undo manager of editeng, then SetUndoManager()
should be called in pairs: once to set it and once to unset it. The
unset should happen before destroying the EditEngine.
This normally works because SwView either has an active text edit and
then its dtor calls SdrEndTextEdit() or it doesn't have an active text
edit.
The broken case was when the text edit was already ended, but the draw
view still had a text edit outliner, which has an EditEngine, which
knows the sw undo manager. The product build deleted the sw undo manager
when deleting the EditEngine, and then later when the SwExtTextInput
dtor wanted to access the sw undo manager, it crashes due to
use-after-free.
Fix the problem by explicitly disposing the undo manager of the draw
view in the dtor of SwView.
Also fix a couple of more places where an SdrObject* is returned and we
didn't check if the result is a nullptr.
Caught by the loolstress tool in online.git:
cp test/data/hello-world.odt /tmp/test.odt
./loolstress ws://localhost:9980 /tmp/test.odt test/traces/writer-hello-shape.txt /tmp/test.odt test/traces/writer-hello-shape.txt /tmp/test.odt test/traces/writer-hello-shape.txt /tmp/test.odt test/traces/writer-mash-text-table.txt /tmp/test.odt test/traces/writer-mash-text-table.txt
Change-Id: Ib838b2adf900b4f3bec63d2d62d432327bc0c6c4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122086
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/svdraw/svdedtv1.cxx | 8 | ||||
-rw-r--r-- | svx/source/svdraw/svdedxv.cxx | 10 |
2 files changed, 17 insertions, 1 deletions
diff --git a/svx/source/svdraw/svdedtv1.cxx b/svx/source/svdraw/svdedtv1.cxx index bdb05d6cce34..307f673da391 100644 --- a/svx/source/svdraw/svdedtv1.cxx +++ b/svx/source/svdraw/svdedtv1.cxx @@ -899,7 +899,13 @@ void SdrEditView::MergeAttrFromMarked(SfxItemSet& rAttr, bool bOnlyHardAttr) con for(size_t a = 0; a < nMarkCount; ++a) { // #80277# merging was done wrong in the prev version - const SfxItemSet& rSet = GetMarkedObjectByIndex(a)->GetMergedItemSet(); + SdrObject *pObj = GetMarkedObjectByIndex(a); + if (!pObj) + { + continue; + } + + const SfxItemSet& rSet = pObj->GetMergedItemSet(); SfxWhichIter aIter(rSet); sal_uInt16 nWhich(aIter.FirstWhich()); diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx index 4769752ebeef..2d0b338b1cd8 100644 --- a/svx/source/svdraw/svdedxv.cxx +++ b/svx/source/svdraw/svdedxv.cxx @@ -2733,6 +2733,16 @@ void SdrObjEditView::ApplyFormatPaintBrushToText(SfxItemSet const& rFormatSet, S rTextObj.NbcSetOutlinerParaObjectForText(std::move(pTemp), pText); } +void SdrObjEditView::DisposeUndoManager() +{ + if (pTextEditOutliner) + { + pTextEditOutliner->SetUndoManager(nullptr); + } + + mpOldTextEditUndoManager = nullptr; +} + void SdrObjEditView::ApplyFormatPaintBrush(SfxItemSet& rFormatSet, bool bNoCharacterFormats, bool bNoParagraphFormats) { |