deweese     2003/11/05 14:21:10

  Modified:    sources/org/apache/batik/bridge SVGSVGElementBridge.java
                        SVGUseElementBridge.java UpdateManager.java
               sources/org/apache/batik/gvt/filter BackgroundRable8Bit.java
               sources/org/apache/batik/swing/svg JSVGComponent.java
               sources/org/apache/batik/util DoublyLinkedList.java
                        RunnableQueue.java
  Log:
  1) Fixed memory leak when 'use'd content changes.
  2) More Race condition work
  3) JSVGCanvas now delays setting Canvas side until after onload event if any.
  
  Revision  Changes    Path
  1.39      +3 -5      
xml-batik/sources/org/apache/batik/bridge/SVGSVGElementBridge.java
  
  Index: SVGSVGElementBridge.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGSVGElementBridge.java,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- SVGSVGElementBridge.java  7 Sep 2003 22:25:27 -0000       1.38
  +++ SVGSVGElementBridge.java  5 Nov 2003 22:21:09 -0000       1.39
  @@ -183,11 +183,9 @@
           if (!isOutermost) {
               // X & Y are ignored on outermost SVG.
               cgn.setPositionTransform(positionTransform);
  -        } else {
  +        } else if (doc == ctx.getDocument()) {
               // <!> FIXME: hack to compute the original document's size
  -            if (ctx.getDocumentSize() == null) {
  -                ctx.setDocumentSize(new Dimension((int)w, (int)h));
  -            }
  +            ctx.setDocumentSize(new Dimension((int)w, (int)h));
           }
           // Set the viewing transform, this is often updated when the
           // component prepares for rendering.
  
  
  
  1.36      +5 -1      
xml-batik/sources/org/apache/batik/bridge/SVGUseElementBridge.java
  
  Index: SVGUseElementBridge.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGUseElementBridge.java,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- SVGUseElementBridge.java  9 Aug 2003 16:58:37 -0000       1.35
  +++ SVGUseElementBridge.java  5 Nov 2003 22:21:09 -0000       1.36
  @@ -198,6 +198,10 @@
           root.appendChild(localRefElement);
   
           SVGOMUseElement ue = (SVGOMUseElement)e;
  +        Node oldRoot = ue.getCSSImportedElementRoot();
  +        if (oldRoot != null) {
  +            disposeTree(oldRoot);
  +        }
           ue.setCSSImportedElementRoot(root);
   
           Element g = localRefElement;
  
  
  
  1.29      +10 -10    xml-batik/sources/org/apache/batik/bridge/UpdateManager.java
  
  Index: UpdateManager.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/UpdateManager.java,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- UpdateManager.java        31 Oct 2003 22:39:41 -0000      1.28
  +++ UpdateManager.java        5 Nov 2003 22:21:10 -0000       1.29
  @@ -313,21 +313,21 @@
        */
       public synchronized void interrupt() {
           if (updateRunnableQueue.getThread() != null) {
  -            if (started) {
  -                dispatchSVGUnLoadEvent();
  -            } else {
  -                // Invoke first to cancel the pending tasks
  -                updateRunnableQueue.preemptLater(new Runnable() {
  -                        public void run() {
  +            // Preempt to cancel the pending tasks
  +            updateRunnableQueue.preemptLater(new Runnable() {
  +                    public void run() {
  +                        if (started) {
  +                            dispatchSVGUnLoadEvent();
  +                        } else {
                               synchronized (UpdateManager.this) {
                                   running = false;
                                   scriptingEnvironment.interrupt();
                                   updateRunnableQueue.getThread().interrupt();
                               }
                           }
  -                    });
  -                resume();
  -            }
  +                    }
  +                });
  +            resume();
           }
       }
   
  
  
  
  1.15      +6 -3      
xml-batik/sources/org/apache/batik/gvt/filter/BackgroundRable8Bit.java
  
  Index: BackgroundRable8Bit.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/gvt/filter/BackgroundRable8Bit.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- BackgroundRable8Bit.java  8 Aug 2003 11:39:15 -0000       1.14
  +++ BackgroundRable8Bit.java  5 Nov 2003 22:21:10 -0000       1.15
  @@ -204,8 +204,11 @@
               // Add our childrens bounds to it...
               CompositeGraphicsNode cgn = (CompositeGraphicsNode)gn;
               r2d = addBounds(cgn, child, r2d);
  -        } else
  -            r2d.add(gn.getPrimitiveBounds());
  +        } else {
  +            Rectangle2D gnb = gn.getPrimitiveBounds();
  +            if (gnb != null)
  +                r2d.add(gnb);
  +        }
   
           return r2d;
       }
  
  
  
  1.91      +39 -42    xml-batik/sources/org/apache/batik/swing/svg/JSVGComponent.java
  
  Index: JSVGComponent.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/swing/svg/JSVGComponent.java,v
  retrieving revision 1.90
  retrieving revision 1.91
  diff -u -r1.90 -r1.91
  --- JSVGComponent.java        3 Nov 2003 11:58:27 -0000       1.90
  +++ JSVGComponent.java        5 Nov 2003 22:21:10 -0000       1.91
  @@ -596,33 +596,26 @@
        * queue thread.  It returns immediately.
        */
       protected void stopThenRun(final Runnable r) {
  -        synchronized (this) {
  -            if (afterStopRunnable != null) {
  -                // Have it run our new runnable, and not
  +        if (afterStopRunnable != null) {
  +            // Have it run our new runnable, and not
                   // run the 'old' runnable.
  -                afterStopRunnable = r;
  -                return;
  -            }
               afterStopRunnable = r;
  +            return;
           }
   
  -        if (documentLoader != null) {
  -            stopProcessing();
  -        } else if (gvtTreeBuilder != null) {
  -            stopProcessing();
  -        } else if (updateManager != null) {
  -            stopProcessing();
  -        } else if (nextUpdateManager != null) {
  -            stopProcessing();
  -        } else if (svgLoadEventDispatcher != null) {
  -            stopProcessing();
  -        }  else {
  -            stopProcessing();
  -            synchronized (this) {
  -                Runnable asr = afterStopRunnable;
  -                afterStopRunnable = null;
  -                asr.run();
  -            }
  +        afterStopRunnable = r;
  +
  +        stopProcessing();
  +
  +        if ((documentLoader         == null) &&
  +            (gvtTreeBuilder         == null) &&
  +            (gvtTreeRenderer        == null) &&
  +            (svgLoadEventDispatcher == null) &&
  +            (nextUpdateManager      == null) &&
  +            (updateManager          == null)) {
  +            Runnable asr = afterStopRunnable;
  +            afterStopRunnable = null;
  +            asr.run();
           }
       }
   
  @@ -749,6 +742,28 @@
           reg.flushCache();
       }
   
  +    public void setGraphicsNode(GraphicsNode gn, boolean createDispatcher) {
  +        Dimension2D dim = bridgeContext.getDocumentSize();
  +        Dimension   mySz = new Dimension((int)dim.getWidth(),
  +                                         (int)dim.getHeight());
  +        JSVGComponent.this.setMySize(mySz);
  +        SVGSVGElement elt = svgDocument.getRootElement();
  +        Dimension d = getSize();
  +        prevComponentSize = d;
  +        if (d.width  < 1) d.width  = 1;
  +        if (d.height < 1) d.height = 1;
  +        AffineTransform at = ViewBox.getViewTransform
  +            (fragmentIdentifier, elt, d.width, d.height);
  +        CanvasGraphicsNode cgn = getCanvasGraphicsNode(gn);
  +        cgn.setViewingTransform(at);
  +        initialTransform = new AffineTransform();
  +        setRenderingTransform(initialTransform, false);
  +        jsvgComponentListener.updateMatrix(initialTransform);
  +        addJGVTComponentListener(jsvgComponentListener);
  +        addComponentListener(jsvgComponentListener);
  +        super.setGraphicsNode(gn, createDispatcher);
  +    }
  +
       /**
        * Creates a new bridge context.
        */
  @@ -1282,24 +1297,6 @@
                   return;
               }
   
  -            Dimension2D dim = bridgeContext.getDocumentSize();
  -            Dimension   mySz = new Dimension((int)dim.getWidth(),
  -                                             (int)dim.getHeight());
  -            JSVGComponent.this.setMySize(mySz);
  -            SVGSVGElement elt = svgDocument.getRootElement();
  -            Dimension d = getSize();
  -            prevComponentSize = d;
  -            if (d.width  < 1) d.width  = 1;
  -            if (d.height < 1) d.height = 1;
  -            AffineTransform at = ViewBox.getViewTransform
  -                (fragmentIdentifier, elt, d.width, d.height);
  -            CanvasGraphicsNode cgn = getCanvasGraphicsNode(e.getGVTRoot());
  -            cgn.setViewingTransform(at);
  -            initialTransform = new AffineTransform();
  -            setRenderingTransform(initialTransform, false);
  -            jsvgComponentListener.updateMatrix(initialTransform);
  -            addJGVTComponentListener(jsvgComponentListener);
  -            addComponentListener(jsvgComponentListener);
               gvtRoot = null;
   
               if (isDynamicDocument && JSVGComponent.this.eventsEnabled) {
  
  
  
  1.4       +13 -0     xml-batik/sources/org/apache/batik/util/DoublyLinkedList.java
  
  Index: DoublyLinkedList.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/util/DoublyLinkedList.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DoublyLinkedList.java     8 Aug 2003 11:39:26 -0000       1.3
  +++ DoublyLinkedList.java     5 Nov 2003 22:21:10 -0000       1.4
  @@ -148,6 +148,19 @@
           head = nde;
       }
   
  +    public void add(int index, Node nde) {
  +        if (nde == null) return;
  +        Node after = head;
  +        while (index != 0) {
  +            after = after.getNext();
  +            index--;
  +        }
  +        nde.insertBefore(after);
  +        if (after == head) 
  +            head=nde;
  +        size++;
  +    }
  +
       /**
        * Adds <tt>nde</tt> to the head of the list.
        * In perl this is called an 'unpop'.  <tt>nde</tt> should
  
  
  
  1.15      +8 -3      xml-batik/sources/org/apache/batik/util/RunnableQueue.java
  
  Index: RunnableQueue.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/util/RunnableQueue.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- RunnableQueue.java        16 Sep 2003 01:12:53 -0000      1.14
  +++ RunnableQueue.java        5 Nov 2003 22:21:10 -0000       1.15
  @@ -111,6 +111,8 @@
        */
       protected DoublyLinkedList list = new DoublyLinkedList();
   
  +    protected int preemptCount = 0;
  +
       /**
        * The object which handle run events.
        */
  @@ -191,6 +193,7 @@
                       if (state == SUSPENDING)
                           continue;
                       l = (Link)list.pop();
  +                    if (preemptCount != 0) preemptCount--;
                       if (l == null) {
                           // No item to run, wait till there is one.
                           list.wait();
  @@ -288,7 +291,8 @@
                   ("RunnableQueue not started or has exited");
           }
           synchronized (list) {
  -            list.unpop(new Link(r));
  +            list.add(preemptCount, new Link(r));
  +            preemptCount++;
               list.notify();
           }
       }
  @@ -315,7 +319,8 @@
   
           LockableLink l = new LockableLink(r);
           synchronized (list) {
  -            list.unpop(l);
  +            list.add(preemptCount, l);
  +            preemptCount++;
               list.notify();
           }
           l.lock();
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to