]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Make the LM clean up on end-of-layout, if possible.
authorAndreas L. Delmelle <adelmelle@apache.org>
Sun, 11 May 2008 12:22:22 +0000 (12:22 +0000)
committerAndreas L. Delmelle <adelmelle@apache.org>
Sun, 11 May 2008 12:22:22 +0000 (12:22 +0000)
Added clearChildNodes() method to FObj to release the reference to the FO's children.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@655309 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/fo/FObj.java
src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java

index 79b04c4d7bd3295a932e497018c6deb39a12a82e..0bbec4d47e16e4ed4468970e1921edda0bc4d015 100644 (file)
@@ -515,6 +515,13 @@ public abstract class FObj extends FONode implements Constants {
         return -1;
     }
     
+    /**
+     * Clears the list of child nodes.
+     */
+    public void clearChildNodes() {
+        this.firstChild = null;
+    }
+    
     /** @return the "id" property. */
     public String getId() {
         return id;
@@ -598,7 +605,7 @@ public abstract class FObj extends FONode implements Constants {
         return (super.toString() + "[@id=" + this.id + "]");
     }
 
-
+    /** Basic {@link FONodeIterator} implementation */
     public class FObjIterator implements FONodeIterator {
         
         private static final int F_NONE_ALLOWED = 0;
index ef32bbc75fb7d2361ea17b9990470941fe395c21..3f2143baeaa7924c2c4230f5c459b2b4cfecd97c 100644 (file)
@@ -147,15 +147,11 @@ public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager
         isFinished = fin;
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public void addAreas(PositionIterator posIter, LayoutContext context) {
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public LinkedList getNextKnuthElements(LayoutContext context,
                                            int alignment) {
         log.warn("null implementation of getNextKnuthElements() called!");
@@ -163,9 +159,7 @@ public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager
         return null;
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public LinkedList getChangedKnuthElements(List oldList,
                                               int alignment) {
         log.warn("null implementation of getChangeKnuthElement() called!");
@@ -390,7 +384,7 @@ public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager
     /**
      * Checks to see if the incoming {@link Position}
      * is the last one for this LM, and if so, calls
-     * {@link #notifyEndOfLayout()}
+     * {@link #notifyEndOfLayout()} and cleans up.
      * 
      * @param pos   the {@link Position} to check
      */
@@ -398,7 +392,32 @@ public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager
         if (pos != null
             && pos.getLM() == this
             && this.isLast(pos)) {
+            
             notifyEndOfLayout();
+            
+            /* References to the child LMs are no longer needed
+             */
+            childLMs = null;
+            curChildLM = null;
+            childLMiter = null;
+            
+            /* markers that qualify have been transferred to the page
+             */
+            markers = null;
+            
+            /* References to the FO's children can be released if the 
+             * LM is a descendant of the FlowLM. For static-content
+             * the FO may still be needed on following pages.
+             */
+            LayoutManager lm = this.parentLM;
+            while (!(lm instanceof FlowLayoutManager
+                        || lm instanceof PageSequenceLayoutManager)) {
+                lm = lm.getParent();
+            }
+            if (lm instanceof FlowLayoutManager) {
+                fobj.clearChildNodes();
+                fobjIter = null;
+            }
         }
     }