https://issues.apache.org/bugzilla/show_bug.cgi?id=46124
Summary: AnimationEngine.removeAnimation doesn't clean up the
"animation sandwich" correctly.
Product: Batik
Version: 1.7
Platform: PC
OS/Version: Windows XP
Status: NEW
Severity: major
Priority: P2
Component: SVG Viewer
AssignedTo: [email protected]
ReportedBy: [EMAIL PROTECTED]
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) {
sandwich = (Sandwich) info.xmlAnimations.remove(ns,
an);
} 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) {
nextHigher.markDirty();
}
moveToBottom(anim);
if (anim.higherAnimation != null) {
anim.higherAnimation.lowerAnimation = null;
}
AnimationInfo animInfo = getAnimationInfo(anim);
Sandwich sandwich = getSandwich(animInfo.target, animInfo.type,
animInfo.attributeNamespaceURI,
animInfo.attributeLocalName);
if (sandwich.animation == anim) {
sandwich.animation = null;
sandwich.lowestAnimation = null;
sandwich.shouldUpdate = true;
removeSandwich(animInfo.target, animInfo.type,
animInfo.attributeNamespaceURI,
animInfo.attributeLocalName);
}
}
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]