From 080e16540946d084838f5ae6d03b24171d2e9c35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hubert=20Figui=C3=A8re?= Date: Tue, 17 Jan 2017 23:58:00 -0500 Subject: [PATCH] Qt: fix memory leaks found when running tests -cleanup objects in tests to fix memory leaks. -optcontent was leaking the headers items https://bugs.freedesktop.org/show_bug.cgi?id=99449 --- qt4/src/poppler-optcontent-private.h | 1 + qt4/src/poppler-optcontent.cc | 2 ++ qt4/tests/check_links.cpp | 2 ++ qt5/src/poppler-optcontent-private.h | 1 + qt5/src/poppler-optcontent.cc | 2 ++ qt5/tests/check_links.cpp | 2 ++ 6 files changed, 10 insertions(+) diff --git a/qt4/src/poppler-optcontent-private.h b/qt4/src/poppler-optcontent-private.h index 25bae04..eb6b4fe 100644 --- a/qt4/src/poppler-optcontent-private.h +++ b/qt4/src/poppler-optcontent-private.h @@ -110,6 +110,7 @@ namespace Poppler OptContentModel *q; QMap m_optContentItems; + QList m_headerOptContentItems; QList m_rbgroups; OptContentItem *m_rootNode; diff --git a/qt4/src/poppler-optcontent.cc b/qt4/src/poppler-optcontent.cc index 84a4d62..6db48af 100644 --- a/qt4/src/poppler-optcontent.cc +++ b/qt4/src/poppler-optcontent.cc @@ -190,6 +190,7 @@ namespace Poppler { qDeleteAll( m_optContentItems ); qDeleteAll( m_rbgroups ); + qDeleteAll( m_headerOptContentItems ); delete m_rootNode; } @@ -217,6 +218,7 @@ namespace Poppler } else if ( orderItem.isString() ) { GooString *label = orderItem.getString(); OptContentItem *header = new OptContentItem ( UnicodeParsedString ( label ) ); + m_headerOptContentItems.append( header ); addChild( parentNode, header ); parentNode = header; lastItem = header; diff --git a/qt4/tests/check_links.cpp b/qt4/tests/check_links.cpp index b5b2dee..d4e7f03 100644 --- a/qt4/tests/check_links.cpp +++ b/qt4/tests/check_links.cpp @@ -68,6 +68,8 @@ void TestLinks::checkDests_xr01() QCOMPARE( dest.destinationName(), QString::fromLatin1("section.2") ); } + qDeleteAll(links); + delete page; delete doc; } diff --git a/qt5/src/poppler-optcontent-private.h b/qt5/src/poppler-optcontent-private.h index 25bae04..eb6b4fe 100644 --- a/qt5/src/poppler-optcontent-private.h +++ b/qt5/src/poppler-optcontent-private.h @@ -110,6 +110,7 @@ namespace Poppler OptContentModel *q; QMap m_optContentItems; + QList m_headerOptContentItems; QList m_rbgroups; OptContentItem *m_rootNode; diff --git a/qt5/src/poppler-optcontent.cc b/qt5/src/poppler-optcontent.cc index 53364ef..7b48393 100644 --- a/qt5/src/poppler-optcontent.cc +++ b/qt5/src/poppler-optcontent.cc @@ -190,6 +190,7 @@ namespace Poppler { qDeleteAll( m_optContentItems ); qDeleteAll( m_rbgroups ); + qDeleteAll( m_headerOptContentItems ); delete m_rootNode; } @@ -217,6 +218,7 @@ namespace Poppler } else if ( orderItem.isString() ) { GooString *label = orderItem.getString(); OptContentItem *header = new OptContentItem ( UnicodeParsedString ( label ) ); + m_headerOptContentItems.append( header ); addChild( parentNode, header ); parentNode = header; lastItem = header; diff --git a/qt5/tests/check_links.cpp b/qt5/tests/check_links.cpp index 4d00272..7a39838 100644 --- a/qt5/tests/check_links.cpp +++ b/qt5/tests/check_links.cpp @@ -68,6 +68,8 @@ void TestLinks::checkDests_xr01() QCOMPARE( dest.destinationName(), QString::fromLatin1("section.2") ); } + qDeleteAll(links); + delete page; delete doc; } -- 2.9.3