poppler/TextOutputDev.cc |   13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

New commits:
commit 9514dceca09af53cf5e920ec76edb3937f87e6ad
Author: Albert Astals Cid <aa...@kde.org>
Date:   Sat Feb 20 22:37:50 2021 +0100

    Make TextSelectionSizer a bit easier to understand standalone
    
    Nothing really changes because it's only used in one place and that
    place called getRegion so there's no leak but looking at the class
    standalone one could think that one would get a leak if getRegion was
    not called.

diff --git a/poppler/TextOutputDev.cc b/poppler/TextOutputDev.cc
index 77ac8d69..a7e9d1ec 100644
--- a/poppler/TextOutputDev.cc
+++ b/poppler/TextOutputDev.cc
@@ -20,7 +20,7 @@
 // Copyright (C) 2006 Jeff Muizelaar <j...@infidigm.net>
 // Copyright (C) 2007, 2008, 2012, 2017 Adrian Johnson <ajohn...@redneon.com>
 // Copyright (C) 2008 Koji Otani <s...@bbr.jp>
-// Copyright (C) 2008, 2010-2012, 2014-2020 Albert Astals Cid <aa...@kde.org>
+// Copyright (C) 2008, 2010-2012, 2014-2021 Albert Astals Cid <aa...@kde.org>
 // Copyright (C) 2008 Pino Toscano <p...@kde.org>
 // Copyright (C) 2008, 2010 Hib Eris <h...@hiberis.nl>
 // Copyright (C) 2009 Ross Moore <r...@maths.mq.edu.au>
@@ -4448,13 +4448,18 @@ class TextSelectionSizer : public TextSelectionVisitor
 {
 public:
     TextSelectionSizer(TextPage *page, double scale);
-    ~TextSelectionSizer() override { }
+    ~TextSelectionSizer() override { delete list; }
 
     void visitBlock(TextBlock *block, TextLine *begin, TextLine *end, const 
PDFRectangle *selection) override {};
     void visitLine(TextLine *line, TextWord *begin, TextWord *end, int 
edge_begin, int edge_end, const PDFRectangle *selection) override;
     void visitWord(TextWord *word, int begin, int end, const PDFRectangle 
*selection) override {};
 
-    std::vector<PDFRectangle *> *getRegion() { return list; }
+    std::vector<PDFRectangle *> *takeRegion()
+    {
+        auto aux = list;
+        list = nullptr;
+        return aux;
+    }
 
 private:
     std::vector<PDFRectangle *> *list;
@@ -4950,7 +4955,7 @@ std::vector<PDFRectangle *> 
*TextPage::getSelectionRegion(const PDFRectangle *se
 
     visitSelection(&sizer, selection, style);
 
-    return sizer.getRegion();
+    return sizer.takeRegion();
 }
 
 GooString *TextPage::getSelectionText(const PDFRectangle *selection, 
SelectionStyle style)
_______________________________________________
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler

Reply via email to