qt4/src/poppler-optcontent-private.h |    2 ++
 qt4/src/poppler-optcontent.cc        |    3 +++
 qt4/tests/check_links.cpp            |    2 ++
 qt5/src/poppler-optcontent-private.h |    2 ++
 qt5/src/poppler-optcontent.cc        |    3 +++
 qt5/tests/check_links.cpp            |    2 ++
 6 files changed, 14 insertions(+)

New commits:
commit e7aad35dcba3449bc8a56de070fea7e09cb64833
Author: Hubert Figuière <[email protected]>
Date:   Tue Jan 17 23:58:00 2017 -0500

    Qt: fix memory leaks found when running tests
    
    -cleanup objects in tests to fix memory leaks.
    -optcontent was leaking the headers items
    
    Bug #99449

diff --git a/qt4/src/poppler-optcontent-private.h 
b/qt4/src/poppler-optcontent-private.h
index 25bae04..b5e5299 100644
--- a/qt4/src/poppler-optcontent-private.h
+++ b/qt4/src/poppler-optcontent-private.h
@@ -3,6 +3,7 @@
  * Copyright (C) 2007, Brad Hards <[email protected]>
  * Copyright (C) 2008, Pino Toscano <[email protected]>
  * Copyright (C) 2016, Albert Astals Cid <[email protected]>
+ * Copyright (C) 2017, Hubert Figuière <[email protected]>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -110,6 +111,7 @@ namespace Poppler
     OptContentModel *q;
 
     QMap<QString, OptContentItem*> m_optContentItems;
+    QList<OptContentItem*> m_headerOptContentItems;
     QList<RadioButtonGroup*> m_rbgroups;
     OptContentItem *m_rootNode;
 
diff --git a/qt4/src/poppler-optcontent.cc b/qt4/src/poppler-optcontent.cc
index 84a4d62..a5b651a 100644
--- a/qt4/src/poppler-optcontent.cc
+++ b/qt4/src/poppler-optcontent.cc
@@ -4,6 +4,7 @@
  * Copyright (C) 2008, 2014, Pino Toscano <[email protected]>
  * Copyright (C) 2008, Carlos Garcia Campos <[email protected]>
  * Copyright (C) 2015, 2016, Albert Astals Cid <[email protected]>
+ * Copyright (C) 2017, Hubert Figuière <[email protected]>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -190,6 +191,7 @@ namespace Poppler
   {
     qDeleteAll( m_optContentItems );
     qDeleteAll( m_rbgroups );
+    qDeleteAll( m_headerOptContentItems );
     delete m_rootNode;
   }
 
@@ -217,6 +219,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..b5e5299 100644
--- a/qt5/src/poppler-optcontent-private.h
+++ b/qt5/src/poppler-optcontent-private.h
@@ -3,6 +3,7 @@
  * Copyright (C) 2007, Brad Hards <[email protected]>
  * Copyright (C) 2008, Pino Toscano <[email protected]>
  * Copyright (C) 2016, Albert Astals Cid <[email protected]>
+ * Copyright (C) 2017, Hubert Figuière <[email protected]>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -110,6 +111,7 @@ namespace Poppler
     OptContentModel *q;
 
     QMap<QString, OptContentItem*> m_optContentItems;
+    QList<OptContentItem*> m_headerOptContentItems;
     QList<RadioButtonGroup*> m_rbgroups;
     OptContentItem *m_rootNode;
 
diff --git a/qt5/src/poppler-optcontent.cc b/qt5/src/poppler-optcontent.cc
index 53364ef..15ba650 100644
--- a/qt5/src/poppler-optcontent.cc
+++ b/qt5/src/poppler-optcontent.cc
@@ -4,6 +4,7 @@
  * Copyright (C) 2008, 2014, Pino Toscano <[email protected]>
  * Copyright (C) 2008, Carlos Garcia Campos <[email protected]>
  * Copyright (C) 2015, 2016, Albert Astals Cid <[email protected]>
+ * Copyright (C) 2017, Hubert Figuière <[email protected]>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -190,6 +191,7 @@ namespace Poppler
   {
     qDeleteAll( m_optContentItems );
     qDeleteAll( m_rbgroups );
+    qDeleteAll( m_headerOptContentItems );
     delete m_rootNode;
   }
 
@@ -217,6 +219,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;
 }
 
_______________________________________________
poppler mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/poppler

Reply via email to