xmlgraphics-batik-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c..@apache.org
Subject svn commit: r522170 - in /xmlgraphics/batik/trunk/sources/org/apache/batik: anim/AnimationEngine.java bridge/SVGAnimationEngine.java
Date Sun, 25 Mar 2007 07:18:47 GMT
Author: cam
Date: Sun Mar 25 00:18:46 2007
New Revision: 522170

URL: http://svn.apache.org/viewvc?view=rev&rev=522170
Log:
1. Fix NPE when the final animation for a given attribute/property is removed.
2. Ensure that when an exception is occurring once per animation tick, these
   are not endlessly reported to the user.

Modified:
    xmlgraphics/batik/trunk/sources/org/apache/batik/anim/AnimationEngine.java
    xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/SVGAnimationEngine.java

Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/anim/AnimationEngine.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/anim/AnimationEngine.java?view=diff&rev=522170&r1=522169&r2=522170
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/anim/AnimationEngine.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/anim/AnimationEngine.java Sun Mar 25
00:18:46 2007
@@ -314,7 +314,9 @@
                 String namespaceURI = (String) e2.getKey1();
                 String localName = (String) e2.getKey2();
                 Sandwich sandwich = (Sandwich) e2.getValue();
-                if (sandwich.shouldUpdate || sandwich.animation.isDirty) {
+                if (sandwich.shouldUpdate ||
+                        sandwich.animation != null
+                            && sandwich.animation.isDirty) {
                     AnimatableValue av = null;
                     boolean usesUnderlying = false;
                     AbstractAnimation anim = sandwich.animation;
@@ -344,7 +346,9 @@
                 Map.Entry e2 = (Map.Entry) j.next();
                 String propertyName = (String) e2.getKey();
                 Sandwich sandwich = (Sandwich) e2.getValue();
-                if (sandwich.shouldUpdate || sandwich.animation.isDirty) {
+                if (sandwich.shouldUpdate ||
+                        sandwich.animation != null
+                            && sandwich.animation.isDirty) {
                     AnimatableValue av = null;
                     boolean usesUnderlying = false;
                     AbstractAnimation anim = sandwich.animation;

Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/SVGAnimationEngine.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/SVGAnimationEngine.java?view=diff&rev=522170&r1=522169&r2=522170
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/SVGAnimationEngine.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/SVGAnimationEngine.java Sun Mar
25 00:18:46 2007
@@ -449,7 +449,7 @@
                 throw new BridgeException(ctx, ex.getElement().getElement(),
                                           ex.getMessage());
             }
-        } catch (BridgeException ex) {
+        } catch (Exception ex) {
             if (ctx.getUserAgent() == null) {
                 ex.printStackTrace();
             } else {
@@ -715,7 +715,7 @@
                             (eng.ctx, ex.getElement().getElement(),
                              ex.getMessage());
                     }
-                } catch (BridgeException ex) {
+                } catch (Exception ex) {
                     if (eng.ctx.getUserAgent() == null) {
                         ex.printStackTrace();
                     } else {
@@ -789,6 +789,19 @@
         protected WeakReference engRef;
 
         /**
+         * The maximum number of consecutive exceptions to allow before
+         * stopping the report of them.
+         */
+        protected static final int MAX_EXCEPTION_COUNT = 10;
+
+        /**
+         * The number of consecutive exceptions that have been thrown.  This is
+         * used to detect when exceptions are occurring every tick, and to stop
+         * reporting them when this happens.
+         */
+        protected int exceptionCount;
+
+        /**
          * Creates a new AnimationTickRunnable.
          */
         public AnimationTickRunnable(RunnableQueue q, SVGAnimationEngine eng) {
@@ -881,11 +894,14 @@
                             (eng.ctx, ex.getElement().getElement(),
                              ex.getMessage());
                     }
-                } catch (BridgeException ex) {
-                    if (eng.ctx.getUserAgent() == null) {
-                        ex.printStackTrace();
-                    } else {
-                        eng.ctx.getUserAgent().displayError(ex);
+                    exceptionCount = 0;
+                } catch (Exception ex) {
+                    if (++exceptionCount < MAX_EXCEPTION_COUNT) {
+                        if (eng.ctx.getUserAgent() == null) {
+                            ex.printStackTrace();
+                        } else {
+                            eng.ctx.getUserAgent().displayError(ex);
+                        }
                     }
                 }
 



Mime
View raw message