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

Caolán McNamara caolanm at redhat.com
Tue Mar 21 09:23:21 UTC 2017


 sd/source/core/sdpage.cxx |   33 ++++++++++++++++++++++++++++++---
 1 file changed, 30 insertions(+), 3 deletions(-)

New commits:
commit d7470bab57640a4499500e3c06ace4fb8ab9c4af
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Mar 20 16:41:11 2017 +0000

    ofz: leaks in animation nodes
    
    there's no dispose option to deal with circular references
    
    Change-Id: I11ad081ab7c98648b7ab87e138f54add04ab07fe
    Reviewed-on: https://gerrit.libreoffice.org/35488
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx
index 740bcb2554a5..421e216cfe8c 100644
--- a/sd/source/core/sdpage.cxx
+++ b/sd/source/core/sdpage.cxx
@@ -50,6 +50,8 @@
 #include <svx/svditer.hxx>
 #include <svx/svdlayer.hxx>
 #include <com/sun/star/animations/XAnimationNode.hpp>
+#include <com/sun/star/animations/XTimeContainer.hpp>
+#include <com/sun/star/container/XEnumerationAccess.hpp>
 #include <com/sun/star/xml/dom/XNode.hpp>
 #include <com/sun/star/xml/dom/XNodeList.hpp>
 #include <com/sun/star/xml/dom/XNamedNodeMap.hpp>
@@ -137,6 +139,33 @@ SdPage::SdPage(SdDrawDocument& rNewDoc, bool bMasterPage)
     }
 }
 
+namespace
+{
+    void clearChildNodes(css::uno::Reference<css::animations::XAnimationNode>& rAnimationNode)
+    {
+        css::uno::Reference<css::container::XEnumerationAccess > xEnumerationAccess(rAnimationNode, UNO_QUERY);
+        if (!xEnumerationAccess.is())
+            return;
+        css::uno::Reference<css::container::XEnumeration> xEnumeration(xEnumerationAccess->createEnumeration(), UNO_QUERY);
+        if (!xEnumeration.is())
+            return;
+        while (xEnumeration->hasMoreElements())
+        {
+            css::uno::Reference<css::animations::XAnimationNode> xChildNode(xEnumeration->nextElement(), UNO_QUERY);
+            if (!xChildNode.is())
+                continue;
+            clearChildNodes(xChildNode);
+            css::uno::Reference<css::animations::XTimeContainer> xAnimationNode(rAnimationNode, UNO_QUERY);
+            if (!xAnimationNode.is())
+            {
+                SAL_WARN("sd.core", "can't remove node child, possible leak");
+                continue;
+            }
+            xAnimationNode->removeChild(xChildNode);
+        }
+    }
+}
+
 /*************************************************************************
 |*
 |* Dtor
@@ -149,9 +178,7 @@ SdPage::~SdPage()
 
     EndListenOutlineText();
 
-    fprintf(stderr, "on dtor %p, have %p\n", this, mxAnimationNode.get());
-
-    mxAnimationNode.clear();
+    clearChildNodes(mxAnimationNode);
 
     delete mpItems;
 


More information about the Libreoffice-commits mailing list