From 4cf51357b75c254e7962dd86140c69474fff129f Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 22 Sep 2021 15:56:06 +0200 Subject: svx: improve SdrObjEditView::DisposeUndoManager() Addresses the comment at , i.e. there can be the case when the undo manager is not an sw::UndoManager (or any other high level undo manager), but it's an EditUndoManager, and in that case we should not clear away the owning pointer to avoid a memory leak. Change-Id: I016cfad0563814d65c8523999c82be7747377171 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122458 Reviewed-by: Miklos Vajna Tested-by: Jenkins --- svx/source/svdraw/svdedxv.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'svx/source') diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx index d71c48027232..3a66fff6b2e2 100644 --- a/svx/source/svdraw/svdedxv.cxx +++ b/svx/source/svdraw/svdedxv.cxx @@ -2737,7 +2737,11 @@ void SdrObjEditView::DisposeUndoManager() { if (pTextEditOutliner) { - pTextEditOutliner->SetUndoManager(nullptr); + if (typeid(pTextEditOutliner->GetUndoManager()) != typeid(EditUndoManager)) + { + // Non-owning pointer, clear it. + pTextEditOutliner->SetUndoManager(nullptr); + } } mpOldTextEditUndoManager = nullptr; -- cgit