[poppler] poppler/TextOutputDev.cc

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Feb 26 15:40:28 UTC 2021


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

New commits:
commit 9514dceca09af53cf5e920ec76edb3937f87e6ad
Author: Albert Astals Cid <aacid at 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 <jeff at infidigm.net>
 // Copyright (C) 2007, 2008, 2012, 2017 Adrian Johnson <ajohnson at redneon.com>
 // Copyright (C) 2008 Koji Otani <sho at bbr.jp>
-// Copyright (C) 2008, 2010-2012, 2014-2020 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2008, 2010-2012, 2014-2021 Albert Astals Cid <aacid at kde.org>
 // Copyright (C) 2008 Pino Toscano <pino at kde.org>
 // Copyright (C) 2008, 2010 Hib Eris <hib at hiberis.nl>
 // Copyright (C) 2009 Ross Moore <ross at 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)


More information about the poppler mailing list