[poppler] 2 commits - poppler/Annot.cc poppler/CharCodeToUnicode.cc poppler/CharCodeToUnicode.h poppler/GfxFont.cc poppler/GfxFont.h

Albert Astals Cid aacid at kemper.freedesktop.org
Thu Apr 5 10:01:38 UTC 2018


 poppler/Annot.cc             |    5 ++---
 poppler/CharCodeToUnicode.cc |    3 ++-
 poppler/CharCodeToUnicode.h  |    3 ++-
 poppler/GfxFont.cc           |   12 ++++--------
 poppler/GfxFont.h            |    7 ++++---
 5 files changed, 14 insertions(+), 16 deletions(-)

New commits:
commit 5804259f22d4d42ed7c37c9efb613910248cd1d4
Author: Albert Astals Cid <albert.astals.cid at kdab.com>
Date:   Thu Apr 5 11:58:50 2018 +0200

    GfxFont::getToUnicode -> const
    
    And we don't need to do the inc/dec ref dance in Annot
    since the GfxFont is still alive while we use it and there's
    no other users to getToUnicode that may keep the CharCodeToUnicode
    for longer time than the GfxFont live

diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index 8c950434..8275ca80 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -36,6 +36,7 @@
 // Copyright (C) 2015 Philipp Reinkemeier <philipp.reinkemeier at offis.de>
 // Copyright (C) 2015 Tamas Szekeres <szekerest at gmail.com>
 // Copyright (C) 2017 Hans-Ulrich Jüttner <huj at froreich-bioscientia.de>
+// Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info at kdab.com>. Work sponsored by the LiMux project of the city of Munich
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -3906,13 +3907,12 @@ void Annot::layoutText(GooString *text, GooString *outBuf, int *i,
     if (noReencode) {
       outBuf->append(uChar);
     } else {
-      CharCodeToUnicode *ccToUnicode = font->getToUnicode();
+      const CharCodeToUnicode *ccToUnicode = font->getToUnicode();
       if (!ccToUnicode) {
         // This assumes an identity CMap.
         outBuf->append((uChar >> 8) & 0xff);
         outBuf->append(uChar & 0xff);
       } else if (ccToUnicode->mapToCharCode(&uChar, &c, 1)) {
-        ccToUnicode->decRefCnt();
         if (font->isCIDFont()) {
           // TODO: This assumes an identity CMap.  It should be extended to
           // handle the general case.
@@ -3923,7 +3923,6 @@ void Annot::layoutText(GooString *text, GooString *outBuf, int *i,
           outBuf->append(c);
         }
       } else {
-        ccToUnicode->decRefCnt();
         error(errSyntaxError, -1, "AnnotWidget::layoutText, cannot convert U+{0:04uX}", uChar);
       }
     }
diff --git a/poppler/GfxFont.cc b/poppler/GfxFont.cc
index df0328b5..2a1aa8ad 100644
--- a/poppler/GfxFont.cc
+++ b/poppler/GfxFont.cc
@@ -32,6 +32,7 @@
 // Copyright (C) 2012, 2017 Thomas Freitag <Thomas.Freitag at alfa.de>
 // Copyright (C) 2013-2016, 2018 Jason Crain <jason at aquaticape.us>
 // Copyright (C) 2014 Olly Betts <olly at survex.com>
+// Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info at kdab.com>. Work sponsored by the LiMux project of the city of Munich
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -1565,8 +1566,7 @@ int Gfx8BitFont::getNextChar(char *s, int len, CharCode *code,
   return 1;
 }
 
-CharCodeToUnicode *Gfx8BitFont::getToUnicode() {
-  ctu->incRefCnt();
+const CharCodeToUnicode *Gfx8BitFont::getToUnicode() const {
   return ctu;
 }
 
@@ -2125,10 +2125,7 @@ int GfxCIDFont::getWMode() {
   return cMap ? cMap->getWMode() : 0;
 }
 
-CharCodeToUnicode *GfxCIDFont::getToUnicode() {
-  if (ctu) {
-    ctu->incRefCnt();
-  }
+const CharCodeToUnicode *GfxCIDFont::getToUnicode() const {
   return ctu;
 }
 
@@ -2324,7 +2321,7 @@ int *GfxCIDFont::getCodeToGIDMap(FoFiTrueType *ff, int *mapsizep) {
   } else {
     error(errSyntaxError, -1, "Unknown character collection {0:t}\n",
       getCollection());
-    if ((ctu = getToUnicode()) != nullptr) {
+    if (ctu) {
       CharCode cid;
       for (cid = 0;cid < n ;cid++) {
 	Unicode *ucode;
@@ -2337,7 +2334,6 @@ int *GfxCIDFont::getCodeToGIDMap(FoFiTrueType *ff, int *mapsizep) {
 	    humap[cid*N_UCS_CANDIDATES+i] = 0;
 	}
       }
-      ctu->decRefCnt();
     }
   }
   // map CID -> Unicode -> GID
diff --git a/poppler/GfxFont.h b/poppler/GfxFont.h
index c2d881e7..1d82ecbf 100644
--- a/poppler/GfxFont.h
+++ b/poppler/GfxFont.h
@@ -23,6 +23,7 @@
 // Copyright (C) 2011, 2012, 2014 Adrian Johnson <ajohnson at redneon.com>
 // Copyright (C) 2015, 2018 Jason Crain <jason at aquaticape.us>
 // Copyright (C) 2015 Thomas Freitag <Thomas.Freitag at alfa.de>
+// Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info at kdab.com>. Work sponsored by the LiMux project of the city of Munich
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -242,7 +243,7 @@ public:
   GBool isBold() { return flags & fontBold; }
 
   // Return the Unicode map.
-  virtual CharCodeToUnicode *getToUnicode() = 0;
+  virtual const CharCodeToUnicode *getToUnicode() const = 0;
 
   // Return the font matrix.
   double *getFontMatrix() { return fontMat; }
@@ -337,7 +338,7 @@ public:
   char **getEncoding() { return enc; }
 
   // Return the Unicode map.
-  CharCodeToUnicode *getToUnicode() override;
+  const CharCodeToUnicode *getToUnicode() const override;
 
   // Return the character name associated with <code>.
   char *getCharName(int code) { return enc[code]; }
@@ -402,7 +403,7 @@ public:
   int getWMode() override;
 
   // Return the Unicode map.
-  CharCodeToUnicode *getToUnicode() override;
+  const CharCodeToUnicode *getToUnicode() const override;
 
   // Get the collection name (<registry>-<ordering>).
   GooString *getCollection();
commit 1eb06156855758e4b1da2adc0334d84d3f857fb1
Author: Albert Astals Cid <albert.astals.cid at kdab.com>
Date:   Thu Apr 5 11:56:57 2018 +0200

    CharCodeToUnicode::mapToCharCode -> const

diff --git a/poppler/CharCodeToUnicode.cc b/poppler/CharCodeToUnicode.cc
index 17df0292..7e0cd895 100644
--- a/poppler/CharCodeToUnicode.cc
+++ b/poppler/CharCodeToUnicode.cc
@@ -25,6 +25,7 @@
 // Copyright (C) 2014 Jiri Slaby <jirislaby at gmail.com>
 // Copyright (C) 2015 Marek Kasik <mkasik at redhat.com>
 // Copyright (C) 2017 Jean Ghali <jghali at libertysurf.fr>
+// Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info at kdab.com>. Work sponsored by the LiMux project of the city of Munich
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -635,7 +636,7 @@ int CharCodeToUnicode::mapToUnicode(CharCode c, Unicode **u) {
   return 0;
 }
 
-int CharCodeToUnicode::mapToCharCode(Unicode* u, CharCode *c, int usize) {
+int CharCodeToUnicode::mapToCharCode(Unicode* u, CharCode *c, int usize) const {
   //look for charcode in map
   if (usize == 1 || (usize > 1 && !(*u & ~0xff))) {
     if (isIdentity) {
diff --git a/poppler/CharCodeToUnicode.h b/poppler/CharCodeToUnicode.h
index 13572217..02b92dcb 100644
--- a/poppler/CharCodeToUnicode.h
+++ b/poppler/CharCodeToUnicode.h
@@ -19,6 +19,7 @@
 // Copyright (C) 2007 Koji Otani <sho at bbr.jp>
 // Copyright (C) 2008, 2011, 2012, 2018 Albert Astals Cid <aacid at kde.org>
 // Copyright (C) 2017 Adrian Johnson <ajohnson at redneon.com>
+// Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info at kdab.com>. Work sponsored by the LiMux project of the city of Munich
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -96,7 +97,7 @@ public:
   int mapToUnicode(CharCode c, Unicode **u);
 
   // Map a Unicode to CharCode.
-  int mapToCharCode(Unicode* u, CharCode *c, int usize);
+  int mapToCharCode(Unicode* u, CharCode *c, int usize) const;
 
   // Return the mapping's length, i.e., one more than the max char
   // code supported by the mapping.


More information about the poppler mailing list