pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1666698 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPageTree.java
Date Sat, 14 Mar 2015 15:53:48 GMT
Author: tilman
Date: Sat Mar 14 15:53:48 2015
New Revision: 1666698

URL: http://svn.apache.org/r1666698
Log:
PDFBOX-2708, PDFBOX-2423: use removeObject() instead of remove() to delete a page from the
tree, update count only when successful, by Radomir Mladenovic

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPageTree.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPageTree.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPageTree.java?rev=1666698&r1=1666697&r2=1666698&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPageTree.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPageTree.java Sat Mar 14
15:53:48 2015
@@ -346,18 +346,19 @@ public class PDPageTree implements COSOb
         // remove from parent's kids
         COSDictionary parent = (COSDictionary) node.getDictionaryObject(COSName.PARENT, COSName.P);
         COSArray kids = (COSArray)parent.getDictionaryObject(COSName.KIDS);
-        kids.remove(node);
-
-        // update ancestor counts
-        do
+        if (kids.removeObject(node))
         {
-            node = (COSDictionary) node.getDictionaryObject(COSName.PARENT, COSName.P);
-            if (node != null)
+            // update ancestor counts
+            do
             {
-                node.setInt(COSName.COUNT, node.getInt(COSName.COUNT) - 1);
+                node = (COSDictionary) node.getDictionaryObject(COSName.PARENT, COSName.P);
+                if (node != null)
+                {
+                    node.setInt(COSName.COUNT, node.getInt(COSName.COUNT) - 1);
+                }
             }
+            while (node != null);
         }
-        while (node != null);
     }
 
     /**



Mime
View raw message