[Libreoffice-commits] core.git: svx/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Wed Sep 22 14:48:23 UTC 2021


 svx/source/svdraw/svdedxv.cxx |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

New commits:
commit 4cf51357b75c254e7962dd86140c69474fff129f
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Wed Sep 22 15:56:06 2021 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Sep 22 16:47:47 2021 +0200

    svx: improve SdrObjEditView::DisposeUndoManager()
    
    Addresses the comment at
    <https://gerrit.libreoffice.org/c/core/+/122151/1/svx/source/svdraw/svdedxv.cxx#2765>,
    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 <vmiklos at collabora.com>
    Tested-by: Jenkins

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;


More information about the Libreoffice-commits mailing list