diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-03-20 16:41:11 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-03-21 09:22:58 +0000 |
commit | d7470bab57640a4499500e3c06ace4fb8ab9c4af (patch) | |
tree | 629347168d0739c6396627e37c845a5048ec3e5e | |
parent | aa483c1d6f3edeccc7afc3329cbd66e361928e56 (diff) |
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@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | sd/source/core/sdpage.cxx | 33 |
1 files changed, 30 insertions, 3 deletions
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; |