Details
-
Bug
-
Status: Resolved
-
Resolution: Fixed
-
1.7
-
None
-
None
-
Operating System: Windows XP
Platform: PC
Description
When a user tries to remove an animation node, the removeAnimation function fails to remove the associated "animation sandwich" object that left in the TargetInfo.otherAnimations internal storage. The sandwich is referring to a 'null' animation which cause null pointer exception when the viewer tries to execute all animations against the target element.
========= Here is the exception ===========
java.lang.NullPointerException
at org.apache.batik.anim.AnimationEngine.tick(AnimationEngine.java:389)
at org.apache.batik.bridge.SVGAnimationEngine.access$601(SVGAnimationEngine.java:99)
at org.apache.batik.bridge.SVGAnimationEngine$AnimationTickRunnable.run(SVGAnimationEngine.java:859)
at org.apache.batik.util.RunnableQueue.run(RunnableQueue.java:237)
at java.lang.Thread.run(Unknown Source)
========== Here is a test case ============
var activeElement = svgDoc.getElementById("theElement");
var anim = svgDoc.createElementNS("http://www.w3.org/2000/svg", "animateMotion");
anim.setAttributeNS(null, "id", "1");
anim.setAttributeNS(null, "dur", "1");
anim.setAttributeNS(null, "path", "m 0, 0 L 0, 5");
anim.setAttributeNS(null, "begin", "indefinite");
anim.setAttributeNS(null, "fill", "freeze");
activeElement.appendChild(anim);
var anim2 = svgDoc.createElementNS("http://www.w3.org/2000/svg", "animate");
anim2.setAttributeNS(null, "id", "2");
anim2.setAttributeNS(null, "dur", "1");
anim2.setAttributeNS(null, "values", "0;26;51;76;102");
anim2.setAttributeNS(null, "attributeName", "x");
anim2.setAttributeNS(null, "begin", "indefinite");
anim2.setAttributeNS(null, "fill", "freeze");
activeElement.appendChild(anim2);
activeElement.removeChild(anim);
anim2.beginElement();
=========== here is the purposed solution ==============
protected Sandwich removeSandwich(AnimationTarget target, short type,
String ns, String an) {
TargetInfo info = getTargetInfo(target);
Sandwich sandwich;
if (type == ANIM_TYPE_XML)
else if (type == ANIM_TYPE_CSS)
{ sandwich = (Sandwich) info.cssAnimations.remove(an); }else
{ sandwich = (Sandwich) info.otherAnimations.remove(an); } return sandwich;
}
public void removeAnimation(AbstractAnimation anim) {
timedDocumentRoot.removeChild(anim.getTimedElement());
AbstractAnimation nextHigher = anim.higherAnimation;
if (nextHigher != null)
moveToBottom(anim);
if (anim.higherAnimation != null)
AnimationInfo animInfo = getAnimationInfo(anim);
Sandwich sandwich = getSandwich(animInfo.target, animInfo.type,
animInfo.attributeNamespaceURI,
animInfo.attributeLocalName);
if (sandwich.animation == anim)
}
Attachments
Attachments
Issue Links
- is duplicated by
-
BATIK-809 Quick Successive User-Triggered Animations Cause Batik to Hang
- Resolved